diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-02-14 08:06:52 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-14 08:06:52 -0800 |
commit | e97d485bb1f1818e2c2118d28507d49cb61ea57b (patch) | |
tree | e1ef9db3f9b95ba4d279ec6c421e0b1c4f2a3b22 /test/passes/optimize-instructions.wast | |
parent | 41faf2409f3e1d8d2dcaf456141f4ce6ac6a3d75 (diff) | |
download | binaryen-e97d485bb1f1818e2c2118d28507d49cb61ea57b.tar.gz binaryen-e97d485bb1f1818e2c2118d28507d49cb61ea57b.tar.bz2 binaryen-e97d485bb1f1818e2c2118d28507d49cb61ea57b.zip |
More simple math opts (#1414)
* optimize more simple math operations: mul of 0, or of 0, and of 0, mul of 1, mul of a power of 2, urem of a power of 2
* fix asm2wasm callImport parsing: the optimizer may get rid of the added offset to a function table
* update js builds
Diffstat (limited to 'test/passes/optimize-instructions.wast')
-rw-r--r-- | test/passes/optimize-instructions.wast | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/test/passes/optimize-instructions.wast b/test/passes/optimize-instructions.wast index 60bfc9b7d..5d1ba7308 100644 --- a/test/passes/optimize-instructions.wast +++ b/test/passes/optimize-instructions.wast @@ -2707,6 +2707,137 @@ ) ) ) + (func $mul-power-2 (param $x i32) (result i32) + (drop + (call $mul-power-2 + (i32.mul + (get_local $x) + (i32.const 4) + ) + ) + ) + (drop + (call $mul-power-2 + (i32.mul + (get_local $x) + (i32.const 5) + ) + ) + ) + (drop + (call $mul-power-2 + (i32.mul + (get_local $x) + (i32.const 1) + ) + ) + ) + (drop + (call $mul-power-2 + (i32.mul + (get_local $x) + (i32.const 0) + ) + ) + ) + (drop + (call $mul-power-2 + (i32.mul + (call $mul-power-2 (i32.const 123)) ;; side effects + (i32.const 0) + ) + ) + ) + (drop + (call $mul-power-2 + (i32.mul + (get_local $x) + (i32.const 0xffffffff) + ) + ) + ) + (drop + (call $mul-power-2 + (i32.mul + (get_local $x) + (i32.const 0x80000000) + ) + ) + ) + (unreachable) + ) + (func $urem-power-2 (param $x i32) (result i32) + (drop + (call $urem-power-2 + (i32.rem_u + (get_local $x) + (i32.const 4) + ) + ) + ) + (drop + (call $urem-power-2 + (i32.rem_u + (get_local $x) + (i32.const 5) + ) + ) + ) + (drop + (call $urem-power-2 + (i32.rem_u + (get_local $x) + (i32.const 1) + ) + ) + ) + (drop + (call $urem-power-2 + (i32.rem_u + (get_local $x) + (i32.const 0) + ) + ) + ) + (drop + (call $urem-power-2 + (i32.rem_u + (get_local $x) + (i32.const 0xffffffff) + ) + ) + ) + (drop + (call $urem-power-2 + (i32.rem_u + (get_local $x) + (i32.const 0x80000000) + ) + ) + ) + (unreachable) + ) + (func $orZero (param $0 i32) (result i32) + (i32.or + (get_local $0) + (i32.const 0) + ) + ) + (func $andZero (param $0 i32) (result i32) + (drop + (i32.and + (get_local $0) + (i32.const 0) + ) + ) + (drop + (i32.and + (call $andZero (i32.const 1234)) ;; side effects + (i32.const 0) + ) + ) + (unreachable) + ) ) (module (import "env" "memory" (memory $0 (shared 256 256))) |