summaryrefslogtreecommitdiff
path: root/test/passes/optimize-instructions.wast
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-11-30 11:12:17 -0800
committerGitHub <noreply@github.com>2017-11-30 11:12:17 -0800
commitbcc6205e83ec98f9b3d5704b79255a853a4ee8bd (patch)
treefdedb36cbc9df17a636abffd082a54f7be6c3092 /test/passes/optimize-instructions.wast
parent290b875970c535f910bbcd5755090f1723447573 (diff)
downloadbinaryen-bcc6205e83ec98f9b3d5704b79255a853a4ee8bd.tar.gz
binaryen-bcc6205e83ec98f9b3d5704b79255a853a4ee8bd.tar.bz2
binaryen-bcc6205e83ec98f9b3d5704b79255a853a4ee8bd.zip
De-morgan's "and" law (#1297)
(eqz X) and (eqz Y) === eqz (X or Y) Normally de-morgan's laws apply only to boolean vars, but for the and (but not or or xor) version, it works in all cases (both sides are true iff X and Y have all zero bits).
Diffstat (limited to 'test/passes/optimize-instructions.wast')
-rw-r--r--test/passes/optimize-instructions.wast23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/passes/optimize-instructions.wast b/test/passes/optimize-instructions.wast
index 4ee2b0c86..34b805f3d 100644
--- a/test/passes/optimize-instructions.wast
+++ b/test/passes/optimize-instructions.wast
@@ -2640,6 +2640,29 @@
(i32.const 0)
)
)
+ (func $de-morgan-2 (param $x i32) (param $y i32)
+ (drop
+ (i32.and (i32.eqz (get_local $x)) (i32.eqz (get_local $y)))
+ )
+ (drop
+ (i32.or (i32.eqz (get_local $x)) (i32.eqz (get_local $y)))
+ )
+ (drop
+ (i32.xor (i32.eqz (get_local $x)) (i32.eqz (get_local $y)))
+ )
+ (drop
+ (i32.and (i32.eqz (get_local $x)) (get_local $y))
+ )
+ (drop
+ (i32.and (get_local $x) (i32.eqz (get_local $y)))
+ )
+ (drop
+ (i32.and (i32.eqz (get_local $x)) (i32.wrap/i64 (i64.const 2)))
+ )
+ (drop
+ (i32.and (i32.wrap/i64 (i64.const 1)) (i32.eqz (get_local $y)))
+ )
+ )
)
(module
(import "env" "memory" (memory $0 (shared 256 256)))