diff options
author | Alon Zakai <azakai@google.com> | 2019-05-07 10:02:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-07 10:02:01 -0700 |
commit | da716eb233f9fe7cefc61d9d1ce54f8b8c9d9126 (patch) | |
tree | f2ee2f838b6a71a90cedce2cf54da1348f3b9348 /test/wasm2js | |
parent | 9384c1d52a8176666e0412b23d9a32ccbc4a8f44 (diff) | |
download | binaryen-da716eb233f9fe7cefc61d9d1ce54f8b8c9d9126.tar.gz binaryen-da716eb233f9fe7cefc61d9d1ce54f8b8c9d9126.tar.bz2 binaryen-da716eb233f9fe7cefc61d9d1ce54f8b8c9d9126.zip |
wasm2js: optimize booleans (#2090)
Diffstat (limited to 'test/wasm2js')
-rw-r--r-- | test/wasm2js/emscripten.2asm.js | 8 | ||||
-rw-r--r-- | test/wasm2js/emscripten.2asm.js.opt | 8 | ||||
-rw-r--r-- | test/wasm2js/emscripten.wast | 10 |
3 files changed, 26 insertions, 0 deletions
diff --git a/test/wasm2js/emscripten.2asm.js b/test/wasm2js/emscripten.2asm.js index 339429be0..91838daf9 100644 --- a/test/wasm2js/emscripten.2asm.js +++ b/test/wasm2js/emscripten.2asm.js @@ -93,6 +93,14 @@ function asmFunc(global, env, buffer) { bools((HEAP16[0 >> 1] | 0) & 1 | 0 | 0) | 0; bools((HEAP32[0 >> 2] | 0) & 1 | 0 | 0) | 0; bools((HEAPU8[0 >> 0] | 0) & 2 | 0 | 0) | 0; + bools(x ^ 1 | 0 | 0) | 0; + if (x ^ 1 | 0) { + bools(2 | 0) | 0 + } + if (x ^ 2 | 0) { + bools(2 | 0) | 0 + } + bools(!(x ^ 1 | 0) | 0) | 0; abort(); } diff --git a/test/wasm2js/emscripten.2asm.js.opt b/test/wasm2js/emscripten.2asm.js.opt index 315279a56..bb4569b7f 100644 --- a/test/wasm2js/emscripten.2asm.js.opt +++ b/test/wasm2js/emscripten.2asm.js.opt @@ -74,6 +74,14 @@ function asmFunc(global, env, buffer) { bools(HEAP16[0 >> 1] & 1); bools(HEAP32[0 >> 2] & 1); bools(HEAPU8[0 | 0] & 2); + bools($0 ^ 1); + if (!$0) { + bools(2) + } + if ($0 ^ 2) { + bools(2) + } + bools(!!$0); abort(); } diff --git a/test/wasm2js/emscripten.wast b/test/wasm2js/emscripten.wast index 07caf4f87..05c290fb9 100644 --- a/test/wasm2js/emscripten.wast +++ b/test/wasm2js/emscripten.wast @@ -106,6 +106,16 @@ (drop (call $bools (i32.and (i32.load16_s (i32.const 0)) (i32.const 1)))) (drop (call $bools (i32.and (i32.load (i32.const 0)) (i32.const 1)))) (drop (call $bools (i32.and (i32.load8_u (i32.const 0)) (i32.const 2)))) + (drop (call $bools (i32.xor (local.get $x) (i32.const 1)))) + (if + (i32.xor (local.get $x) (i32.const 1)) + (drop (call $bools (i32.const 2))) + ) + (if + (i32.xor (local.get $x) (i32.const 2)) + (drop (call $bools (i32.const 2))) + ) + (drop (call $bools (i32.eqz (i32.xor (local.get $x) (i32.const 1))))) (unreachable) ) ) |