diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-02-24 15:34:58 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-02-24 15:34:58 -0800 |
commit | 372247582585c1dd3f0d280e4e5b49e48efb9799 (patch) | |
tree | 2650219b40ff85864c7bb17c4ff84f70d71e2e5a /src/parseTools.js | |
parent | 17c578e3837405877b9c2052220ffb91b5f47ba2 (diff) |
do not emit direct multiplies of <32 bit in asm, asm only has 32-bit multiply
Diffstat (limited to 'src/parseTools.js')
-rw-r--r-- | src/parseTools.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index 7d1a7cd9..ae5831ae 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1393,7 +1393,8 @@ function getFastValue(a, op, b, type) { if (!(type in Runtime.FLOAT_TYPES)) { // if guaranteed small enough to not overflow into a double, do a normal multiply var bits = getBits(type) || 32; // default is 32-bit multiply for things like getelementptr indexes - if ((isNumber(a) && Math.abs(a) < TWO_TWENTY) || (isNumber(b) && Math.abs(b) < TWO_TWENTY) || bits < 32) { + // Note that we can emit simple multiple in non-asm.js mode, but asm.js will not parse "16-bit" multiple, so must do imul there + if ((isNumber(a) && Math.abs(a) < TWO_TWENTY) || (isNumber(b) && Math.abs(b) < TWO_TWENTY) || (bits < 32 && !ASM_JS)) { return '(((' + a + ')*(' + b + '))&' + ((Math.pow(2, bits)-1)|0) + ')'; // keep a non-eliminatable coercion directly on this } return 'Math.imul(' + a + ',' + b + ')'; |