diff options
author | Max Graey <maxgraey@gmail.com> | 2020-10-18 20:56:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-18 10:56:07 -0700 |
commit | 8d8e1c53aa1b03ad4285437a6c41bc86f86731ca (patch) | |
tree | 8e3cc5c403f5d744d8be2d80d2913967ad1d3179 /test/passes/optimize-instructions_all-features.wast | |
parent | bde6878ee30baeda4a1ee82fb9c933768a17b6b2 (diff) | |
download | binaryen-8d8e1c53aa1b03ad4285437a6c41bc86f86731ca.tar.gz binaryen-8d8e1c53aa1b03ad4285437a6c41bc86f86731ca.tar.bz2 binaryen-8d8e1c53aa1b03ad4285437a6c41bc86f86731ca.zip |
Optimize comparisons with 0/1 in boolean context (#3240)
i32(bool(x)) != 0 ==> i32(bool(x))
i64(bool(x)) & 1 ==> i64(bool(x))
Also:
* clean up related matching rules in optimizeWithConstantOnRight
* add more explanations about isPowerOf2Float & rename to
isPowerOfTwoInvertibleFloat
Diffstat (limited to 'test/passes/optimize-instructions_all-features.wast')
-rw-r--r-- | test/passes/optimize-instructions_all-features.wast | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/passes/optimize-instructions_all-features.wast b/test/passes/optimize-instructions_all-features.wast index cf3938cdf..934ccc977 100644 --- a/test/passes/optimize-instructions_all-features.wast +++ b/test/passes/optimize-instructions_all-features.wast @@ -4395,6 +4395,30 @@ ) (i64.const 1) )) + ;; i32(bool(expr)) != 0 -> i32(bool(expr)) + (drop (i32.ne + (i32.and + (local.get $x) + (i32.const 1) + ) + (i32.const 0) + )) + ;; i32(bool(expr)) != 0 -> i32(bool(expr)) + (drop (i32.ne + (i64.ne + (local.get $y) + (i64.const 0) + ) + (i32.const 0) + )) + ;; (i32(expr) != 0) != 0 -> (expr != 0) + (drop (i32.ne + (i32.ne + (local.get $x) + (i32.const 0) + ) + (i32.const 0) + )) ) (func $optimize-bitwise-oprations (param $x i32) (param $y i32) (param $z i64) (param $w i64) ;; ~(1 << x) -> rotl(-2, x) |