aboutsummaryrefslogtreecommitdiff
path: root/tools/js-optimizer.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-02-03 23:38:50 -0500
committerAlon Zakai <alonzakai@gmail.com>2014-02-03 23:38:50 -0500
commit3136112a0000d94024851347b3fc03e178481add (patch)
treeaf57b417ab8435f4fe73c5b983756ec0249b4663 /tools/js-optimizer.js
parentb6782ad900f6f4487aba973fbd04e8e232a33e79 (diff)
proper fix for simplifying f32-int bitcasts
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r--tools/js-optimizer.js11
1 files changed, 4 insertions, 7 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 2ae3ce47..905e80fc 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -709,10 +709,6 @@ function simplifyExpressions(ast) {
}
}
});
- var hasFloat = false;
- for (var v in asmData.vars) {
- if (asmData.vars[v] === ASM_FLOAT) hasFloat = true;
- }
for (var v in bitcastVars) {
var info = bitcastVars[v];
// good variables define only one type, use only one type, have definitions and uses, and define as a different type than they use
@@ -726,7 +722,7 @@ function simplifyExpressions(ast) {
if (correct === 'HEAP32') {
define[3] = ['binary', '|', define[3], ['num', 0]];
} else {
- define[3] = ['unary-prefix', '+', define[3]];
+ define[3] = makeAsmCoercion(define[3], asmPreciseF32 ? ASM_FLOAT : ASM_DOUBLE);
}
// do we want a simplifybitops on the new values here?
});
@@ -735,7 +731,7 @@ function simplifyExpressions(ast) {
});
var correctType;
switch(asmData.vars[v]) {
- case ASM_INT: correctType = hasFloat ? ASM_FLOAT : ASM_DOUBLE; break;
+ case ASM_INT: correctType = asmPreciseF32 ? ASM_FLOAT : ASM_DOUBLE; break;
case ASM_FLOAT: case ASM_DOUBLE: correctType = ASM_INT; break;
}
asmData.vars[v] = correctType;
@@ -5162,7 +5158,7 @@ function asmLastOpts(ast) {
// Passes table
-var minifyWhitespace = false, printMetadata = true, asm = false, last = false;
+var minifyWhitespace = false, printMetadata = true, asm = false, asmPreciseF32 = false, last = false;
var passes = {
// passes
@@ -5191,6 +5187,7 @@ var passes = {
minifyWhitespace: function() { minifyWhitespace = true },
noPrintMetadata: function() { printMetadata = false },
asm: function() { asm = true },
+ asmPreciseF32: function() { asmPreciseF32 = true },
last: function() { last = true },
};