diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-12-07 14:06:46 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-12-07 14:06:46 -0800 |
commit | c44dc7b23fae93222c8a38da53e50c0b0aaa0366 (patch) | |
tree | e45447b31e4f4cb1dbea1f1936cdd70082a6f172 | |
parent | 09771ea21a3f30ade4a8abb7482fdd3b6eaaba7a (diff) | |
download | binaryen-c44dc7b23fae93222c8a38da53e50c0b0aaa0366.tar.gz binaryen-c44dc7b23fae93222c8a38da53e50c0b0aaa0366.tar.bz2 binaryen-c44dc7b23fae93222c8a38da53e50c0b0aaa0366.zip |
use Math.imul in wasm2asm
-rw-r--r-- | src/shared-constants.h | 1 | ||||
-rw-r--r-- | src/wasm2asm.h | 2 | ||||
-rw-r--r-- | test/emcc_O2_hello_world.2asm.js | 2 |
3 files changed, 3 insertions, 2 deletions
diff --git a/src/shared-constants.h b/src/shared-constants.h index b052f54df..a67475303 100644 --- a/src/shared-constants.h +++ b/src/shared-constants.h @@ -56,6 +56,7 @@ cashew::IString GLOBAL("global"), BUFFER("buffer"), ENV("env"), FAKE_RETURN("fake_return_waka123"), + MATH_IMUL("Math_imul"), MATH_CLZ32("Math_clz32"), MATH_CTZ32("Math_ctz32"), MATH_POPCNT32("Math_popcnt32"), diff --git a/src/wasm2asm.h b/src/wasm2asm.h index 4fab55f86..0dec0722c 100644 --- a/src/wasm2asm.h +++ b/src/wasm2asm.h @@ -850,7 +850,7 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) { switch (curr->op) { case Add: ret = ValueBuilder::makeBinary(left, PLUS, right); break; case Sub: ret = ValueBuilder::makeBinary(left, MINUS, right); break; - case Mul: ret = ValueBuilder::makeBinary(left, MUL, right); break; + case Mul: return ValueBuilder::makeCall(MATH_IMUL, left, right); // TODO: when one operand is a small int, emit a multiply case DivS: ret = ValueBuilder::makeBinary(left, DIV, right); break; case DivU: ret = ValueBuilder::makeBinary(left, DIV, right); break; case RemS: ret = ValueBuilder::makeBinary(left, MOD, right); break; diff --git a/test/emcc_O2_hello_world.2asm.js b/test/emcc_O2_hello_world.2asm.js index 3c153067c..98331025f 100644 --- a/test/emcc_O2_hello_world.2asm.js +++ b/test/emcc_O2_hello_world.2asm.js @@ -2287,7 +2287,7 @@ function asmFunc(global, env, buffer) { i4 = i4 | 0; var i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, wasm2asm_i32$0 = 0; topmost : { - i5 = i3 * i2 | 0; + i5 = Math_imul(i3, i2); if ((HEAPU32[(i4 + 76 | 0) >> 2] | 0 | 0) > (4294967295 | 0)) { i6 = (___lockfile(i4 | 0) | 0 | 0) == (0 | 0); i7 = ___fwritex(i1 | 0, i5 | 0, i4 | 0) | 0; |