summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/passes/OptimizeInstructions.wast15
-rw-r--r--src/passes/OptimizeInstructions.wast.processed15
-rw-r--r--test/emcc_hello_world.fromasm440
-rw-r--r--test/emcc_hello_world.fromasm.imprecise440
-rw-r--r--test/passes/optimize-instructions.txt4
-rw-r--r--test/passes/optimize-instructions.wast8
6 files changed, 334 insertions, 588 deletions
diff --git a/src/passes/OptimizeInstructions.wast b/src/passes/OptimizeInstructions.wast
index 48a4e2c9d..d5f8148ec 100644
--- a/src/passes/OptimizeInstructions.wast
+++ b/src/passes/OptimizeInstructions.wast
@@ -34,6 +34,21 @@
(call_import $any.expr (i32.const 1))
)
)
+ ;; eqz^2 is eliminatable if the output is boolean (note that for if-else, the above rule handles it in two operations)
+ (block
+ (if
+ (i32.eqz
+ (i32.eqz
+ (call_import $i32.expr (i32.const 0))
+ )
+ )
+ (call_import $any.expr (i32.const 1))
+ )
+ (if
+ (call_import $i32.expr (i32.const 0))
+ (call_import $any.expr (i32.const 1))
+ )
+ )
;; equal 0 => eqz
(block
(i32.eq
diff --git a/src/passes/OptimizeInstructions.wast.processed b/src/passes/OptimizeInstructions.wast.processed
index 13ccc8241..78e5e7476 100644
--- a/src/passes/OptimizeInstructions.wast.processed
+++ b/src/passes/OptimizeInstructions.wast.processed
@@ -34,6 +34,21 @@
"(call_import $any.expr (i32.const 1))\n"
")\n"
")\n"
+";; eqz^2 is eliminatable if the output is boolean (note that for if-else, the above rule handles it in two operations)\n"
+"(block\n"
+"(if\n"
+"(i32.eqz\n"
+"(i32.eqz\n"
+"(call_import $i32.expr (i32.const 0))\n"
+")\n"
+")\n"
+"(call_import $any.expr (i32.const 1))\n"
+")\n"
+"(if\n"
+"(call_import $i32.expr (i32.const 0))\n"
+"(call_import $any.expr (i32.const 1))\n"
+")\n"
+")\n"
";; equal 0 => eqz\n"
"(block\n"
"(i32.eq\n"
diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm
index e70db6294..10da1e436 100644
--- a/test/emcc_hello_world.fromasm
+++ b/test/emcc_hello_world.fromasm
@@ -626,13 +626,9 @@
(get_local $5)
)
(if
- (i32.eqz
- (i32.eqz
- (call_import $___syscall54
- (i32.const 54)
- (get_local $3)
- )
- )
+ (call_import $___syscall54
+ (i32.const 54)
+ (get_local $3)
)
(i32.store8 offset=75
(get_local $0)
@@ -790,13 +786,9 @@
(i32.const 44)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $1
- (i32.load
- (i32.const 40)
- )
- )
+ (tee_local $1
+ (i32.load
+ (i32.const 40)
)
)
(block
@@ -839,11 +831,7 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (get_local $0)
- )
- )
+ (get_local $0)
(call $___unlockfile
(get_local $1)
)
@@ -1599,11 +1587,7 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (get_local $12)
- )
- )
+ (get_local $12)
(call $___unlockfile
(get_local $0)
)
@@ -2396,19 +2380,15 @@
)
)
(br_if $while-out$5
- (i32.eqz
- (i32.eqz
+ (i32.and
+ (i32.xor
(i32.and
- (i32.xor
- (i32.and
- (get_local $6)
- (i32.const -2139062144)
- )
- (i32.const -2139062144)
- )
- (get_local $1)
+ (get_local $6)
+ (i32.const -2139062144)
)
+ (i32.const -2139062144)
)
+ (get_local $1)
)
)
(set_local $1
@@ -3486,11 +3466,7 @@
(i32.const 0)
)
(if
- (i32.eqz
- (i32.eqz
- (get_local $11)
- )
- )
+ (get_local $11)
(block
(set_local $24
(i32.const -1)
@@ -3881,11 +3857,7 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (get_local $21)
- )
- )
+ (get_local $21)
(block
(set_local $24
(i32.const -1)
@@ -6516,14 +6488,10 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $1
- (i32.and
- (get_local $18)
- (i32.const 8)
- )
- )
+ (tee_local $1
+ (i32.and
+ (get_local $18)
+ (i32.const 8)
)
)
(block
@@ -6592,21 +6560,17 @@
)
)
(br_if $while-out$102
- (i32.eqz
- (i32.eqz
- (i32.and
- (call_import $i32u-rem
- (get_local $1)
- (tee_local $5
- (i32.mul
- (get_local $5)
- (i32.const 10)
- )
- )
+ (i32.and
+ (call_import $i32u-rem
+ (get_local $1)
+ (tee_local $5
+ (i32.mul
+ (get_local $5)
+ (i32.const 10)
)
- (i32.const -1)
)
)
+ (i32.const -1)
)
)
(br $while-in$103)
@@ -7035,11 +6999,7 @@
)
(block $do-once$114
(if
- (i32.eqz
- (i32.eqz
- (get_local $1)
- )
- )
+ (get_local $1)
(block
(br_if $do-once$114
(i32.eqz
@@ -7270,15 +7230,11 @@
)
)
(br_if $do-once$122
- (i32.eqz
- (i32.eqz
- (i32.and
- (i32.load
- (get_local $0)
- )
- (i32.const 32)
- )
+ (i32.and
+ (i32.load
+ (get_local $0)
)
+ (i32.const 32)
)
)
(drop
@@ -8384,16 +8340,12 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (i32.load
- (i32.add
- (get_local $4)
- (i32.shl
- (get_local $1)
- (i32.const 2)
- )
- )
+ (i32.load
+ (i32.add
+ (get_local $4)
+ (i32.shl
+ (get_local $1)
+ (i32.const 2)
)
)
)
@@ -8952,11 +8904,7 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (get_local $3)
- )
- )
+ (get_local $3)
(block
(set_local $1
(get_local $0)
@@ -9232,42 +9180,38 @@
)
(block
(if
- (i32.eqz
- (i32.eqz
- (i32.and
- (tee_local $25
+ (i32.and
+ (tee_local $25
+ (i32.shr_u
+ (tee_local $4
+ (i32.load
+ (i32.const 176)
+ )
+ )
+ (tee_local $22
(i32.shr_u
- (tee_local $4
- (i32.load
- (i32.const 176)
- )
- )
- (tee_local $22
- (i32.shr_u
- (tee_local $6
- (select
- (i32.const 16)
- (i32.and
- (i32.add
- (get_local $0)
- (i32.const 11)
- )
- (i32.const -8)
- )
- (i32.lt_u
- (get_local $0)
- (i32.const 11)
- )
+ (tee_local $6
+ (select
+ (i32.const 16)
+ (i32.and
+ (i32.add
+ (get_local $0)
+ (i32.const 11)
)
+ (i32.const -8)
+ )
+ (i32.lt_u
+ (get_local $0)
+ (i32.const 11)
)
- (i32.const 3)
)
)
+ (i32.const 3)
)
)
- (i32.const 3)
)
)
+ (i32.const 3)
)
(block
(set_local $2
@@ -9413,11 +9357,7 @@
)
(block
(if
- (i32.eqz
- (i32.eqz
- (get_local $25)
- )
- )
+ (get_local $25)
(block
(set_local $1
(i32.sub
@@ -9665,11 +9605,7 @@
(get_local $9)
)
(if
- (i32.eqz
- (i32.eqz
- (get_local $7)
- )
- )
+ (get_local $7)
(block
(set_local $0
(i32.load
@@ -9784,13 +9720,9 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load
- (i32.const 180)
- )
- )
+ (tee_local $0
+ (i32.load
+ (i32.const 180)
)
)
(block
@@ -10053,16 +9985,12 @@
(loop $while-in$11
(block $while-out$10
(if
- (i32.eqz
- (i32.eqz
- (tee_local $2
- (i32.load
- (tee_local $5
- (i32.add
- (get_local $4)
- (i32.const 20)
- )
- )
+ (tee_local $2
+ (i32.load
+ (tee_local $5
+ (i32.add
+ (get_local $4)
+ (i32.const 20)
)
)
)
@@ -10176,11 +10104,7 @@
)
(block $do-once$12
(if
- (i32.eqz
- (i32.eqz
- (get_local $1)
- )
- )
+ (get_local $1)
(block
(if
(i32.eq
@@ -10284,13 +10208,9 @@
(get_local $1)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $1
- (i32.load offset=16
- (get_local $10)
- )
- )
+ (tee_local $1
+ (i32.load offset=16
+ (get_local $10)
)
)
(if
@@ -10312,13 +10232,9 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load offset=20
- (get_local $10)
- )
- )
+ (tee_local $0
+ (i32.load offset=20
+ (get_local $10)
)
)
(if
@@ -10406,13 +10322,9 @@
(get_local $7)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load
- (i32.const 184)
- )
- )
+ (tee_local $0
+ (i32.load
+ (i32.const 184)
)
)
(block
@@ -11071,13 +10983,9 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load offset=16
- (get_local $24)
- )
- )
+ (tee_local $0
+ (i32.load offset=16
+ (get_local $24)
)
)
(block
@@ -11212,16 +11120,12 @@
(loop $while-in$24
(block $while-out$23
(if
- (i32.eqz
- (i32.eqz
- (tee_local $2
- (i32.load
- (tee_local $7
- (i32.add
- (get_local $8)
- (i32.const 20)
- )
- )
+ (tee_local $2
+ (i32.load
+ (tee_local $7
+ (i32.add
+ (get_local $8)
+ (i32.const 20)
)
)
)
@@ -11335,11 +11239,7 @@
)
(block $do-once$25
(if
- (i32.eqz
- (i32.eqz
- (get_local $1)
- )
- )
+ (get_local $1)
(block
(if
(i32.eq
@@ -11443,13 +11343,9 @@
(get_local $1)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $1
- (i32.load offset=16
- (get_local $13)
- )
- )
+ (tee_local $1
+ (i32.load offset=16
+ (get_local $13)
)
)
(if
@@ -11471,13 +11367,9 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load offset=20
- (get_local $13)
- )
- )
+ (tee_local $0
+ (i32.load offset=20
+ (get_local $13)
)
)
(if
@@ -12307,13 +12199,9 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load
- (i32.const 616)
- )
- )
+ (tee_local $0
+ (i32.load
+ (i32.const 616)
)
)
(if
@@ -12562,13 +12450,9 @@
)
(block
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load
- (i32.const 616)
- )
- )
+ (tee_local $0
+ (i32.load
+ (i32.const 616)
)
)
(br_if $do-once$39
@@ -13477,16 +13361,12 @@
(loop $while-in$62
(block $while-out$61
(if
- (i32.eqz
- (i32.eqz
- (tee_local $1
- (i32.load
- (tee_local $20
- (i32.add
- (get_local $2)
- (i32.const 20)
- )
- )
+ (tee_local $1
+ (i32.load
+ (tee_local $20
+ (i32.add
+ (get_local $2)
+ (i32.const 20)
)
)
)
@@ -13707,16 +13587,12 @@
(get_local $0)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load
- (tee_local $2
- (i32.add
- (get_local $3)
- (i32.const 16)
- )
- )
+ (tee_local $0
+ (i32.load
+ (tee_local $2
+ (i32.add
+ (get_local $3)
+ (i32.const 16)
)
)
)
@@ -15603,16 +15479,12 @@
(loop $while-in$5
(block $while-out$4
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load
- (tee_local $13
- (i32.add
- (get_local $2)
- (i32.const 20)
- )
- )
+ (tee_local $0
+ (i32.load
+ (tee_local $13
+ (i32.add
+ (get_local $2)
+ (i32.const 20)
)
)
)
@@ -15844,16 +15716,12 @@
(get_local $8)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $1
- (i32.load
- (tee_local $2
- (i32.add
- (get_local $4)
- (i32.const 16)
- )
- )
+ (tee_local $1
+ (i32.load
+ (tee_local $2
+ (i32.add
+ (get_local $4)
+ (i32.const 16)
)
)
)
@@ -16278,16 +16146,12 @@
(loop $while-in$13
(block $while-out$12
(if
- (i32.eqz
- (i32.eqz
- (tee_local $1
- (i32.load
- (tee_local $7
- (i32.add
- (get_local $2)
- (i32.const 20)
- )
- )
+ (tee_local $1
+ (i32.load
+ (tee_local $7
+ (i32.add
+ (get_local $2)
+ (i32.const 20)
)
)
)
@@ -16404,11 +16268,7 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (get_local $0)
- )
- )
+ (get_local $0)
(block
(if
(i32.eq
@@ -16512,16 +16372,12 @@
(get_local $0)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load
- (tee_local $2
- (i32.add
- (get_local $9)
- (i32.const 16)
- )
- )
+ (tee_local $0
+ (i32.load
+ (tee_local $2
+ (i32.add
+ (get_local $9)
+ (i32.const 16)
)
)
)
@@ -16545,13 +16401,9 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load offset=4
- (get_local $2)
- )
- )
+ (tee_local $0
+ (i32.load offset=4
+ (get_local $2)
)
)
(if
diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise
index 014f28dd2..bcdebdd99 100644
--- a/test/emcc_hello_world.fromasm.imprecise
+++ b/test/emcc_hello_world.fromasm.imprecise
@@ -619,13 +619,9 @@
(get_local $5)
)
(if
- (i32.eqz
- (i32.eqz
- (call_import $___syscall54
- (i32.const 54)
- (get_local $3)
- )
- )
+ (call_import $___syscall54
+ (i32.const 54)
+ (get_local $3)
)
(i32.store8 offset=75
(get_local $0)
@@ -783,13 +779,9 @@
(i32.const 44)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $1
- (i32.load
- (i32.const 40)
- )
- )
+ (tee_local $1
+ (i32.load
+ (i32.const 40)
)
)
(block
@@ -832,11 +824,7 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (get_local $0)
- )
- )
+ (get_local $0)
(call $___unlockfile
(get_local $1)
)
@@ -1592,11 +1580,7 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (get_local $12)
- )
- )
+ (get_local $12)
(call $___unlockfile
(get_local $0)
)
@@ -2389,19 +2373,15 @@
)
)
(br_if $while-out$5
- (i32.eqz
- (i32.eqz
+ (i32.and
+ (i32.xor
(i32.and
- (i32.xor
- (i32.and
- (get_local $6)
- (i32.const -2139062144)
- )
- (i32.const -2139062144)
- )
- (get_local $1)
+ (get_local $6)
+ (i32.const -2139062144)
)
+ (i32.const -2139062144)
)
+ (get_local $1)
)
)
(set_local $1
@@ -3479,11 +3459,7 @@
(i32.const 0)
)
(if
- (i32.eqz
- (i32.eqz
- (get_local $11)
- )
- )
+ (get_local $11)
(block
(set_local $24
(i32.const -1)
@@ -3874,11 +3850,7 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (get_local $21)
- )
- )
+ (get_local $21)
(block
(set_local $24
(i32.const -1)
@@ -6509,14 +6481,10 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $1
- (i32.and
- (get_local $18)
- (i32.const 8)
- )
- )
+ (tee_local $1
+ (i32.and
+ (get_local $18)
+ (i32.const 8)
)
)
(block
@@ -6585,21 +6553,17 @@
)
)
(br_if $while-out$102
- (i32.eqz
- (i32.eqz
- (i32.and
- (i32.rem_u
- (get_local $1)
- (tee_local $5
- (i32.mul
- (get_local $5)
- (i32.const 10)
- )
- )
+ (i32.and
+ (i32.rem_u
+ (get_local $1)
+ (tee_local $5
+ (i32.mul
+ (get_local $5)
+ (i32.const 10)
)
- (i32.const -1)
)
)
+ (i32.const -1)
)
)
(br $while-in$103)
@@ -7028,11 +6992,7 @@
)
(block $do-once$114
(if
- (i32.eqz
- (i32.eqz
- (get_local $1)
- )
- )
+ (get_local $1)
(block
(br_if $do-once$114
(i32.eqz
@@ -7263,15 +7223,11 @@
)
)
(br_if $do-once$122
- (i32.eqz
- (i32.eqz
- (i32.and
- (i32.load
- (get_local $0)
- )
- (i32.const 32)
- )
+ (i32.and
+ (i32.load
+ (get_local $0)
)
+ (i32.const 32)
)
)
(drop
@@ -8377,16 +8333,12 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (i32.load
- (i32.add
- (get_local $4)
- (i32.shl
- (get_local $1)
- (i32.const 2)
- )
- )
+ (i32.load
+ (i32.add
+ (get_local $4)
+ (i32.shl
+ (get_local $1)
+ (i32.const 2)
)
)
)
@@ -8945,11 +8897,7 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (get_local $3)
- )
- )
+ (get_local $3)
(block
(set_local $1
(get_local $0)
@@ -9225,42 +9173,38 @@
)
(block
(if
- (i32.eqz
- (i32.eqz
- (i32.and
- (tee_local $25
+ (i32.and
+ (tee_local $25
+ (i32.shr_u
+ (tee_local $4
+ (i32.load
+ (i32.const 176)
+ )
+ )
+ (tee_local $22
(i32.shr_u
- (tee_local $4
- (i32.load
- (i32.const 176)
- )
- )
- (tee_local $22
- (i32.shr_u
- (tee_local $6
- (select
- (i32.const 16)
- (i32.and
- (i32.add
- (get_local $0)
- (i32.const 11)
- )
- (i32.const -8)
- )
- (i32.lt_u
- (get_local $0)
- (i32.const 11)
- )
+ (tee_local $6
+ (select
+ (i32.const 16)
+ (i32.and
+ (i32.add
+ (get_local $0)
+ (i32.const 11)
)
+ (i32.const -8)
+ )
+ (i32.lt_u
+ (get_local $0)
+ (i32.const 11)
)
- (i32.const 3)
)
)
+ (i32.const 3)
)
)
- (i32.const 3)
)
)
+ (i32.const 3)
)
(block
(set_local $2
@@ -9406,11 +9350,7 @@
)
(block
(if
- (i32.eqz
- (i32.eqz
- (get_local $25)
- )
- )
+ (get_local $25)
(block
(set_local $1
(i32.sub
@@ -9658,11 +9598,7 @@
(get_local $9)
)
(if
- (i32.eqz
- (i32.eqz
- (get_local $7)
- )
- )
+ (get_local $7)
(block
(set_local $0
(i32.load
@@ -9777,13 +9713,9 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load
- (i32.const 180)
- )
- )
+ (tee_local $0
+ (i32.load
+ (i32.const 180)
)
)
(block
@@ -10046,16 +9978,12 @@
(loop $while-in$11
(block $while-out$10
(if
- (i32.eqz
- (i32.eqz
- (tee_local $2
- (i32.load
- (tee_local $5
- (i32.add
- (get_local $4)
- (i32.const 20)
- )
- )
+ (tee_local $2
+ (i32.load
+ (tee_local $5
+ (i32.add
+ (get_local $4)
+ (i32.const 20)
)
)
)
@@ -10169,11 +10097,7 @@
)
(block $do-once$12
(if
- (i32.eqz
- (i32.eqz
- (get_local $1)
- )
- )
+ (get_local $1)
(block
(if
(i32.eq
@@ -10277,13 +10201,9 @@
(get_local $1)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $1
- (i32.load offset=16
- (get_local $10)
- )
- )
+ (tee_local $1
+ (i32.load offset=16
+ (get_local $10)
)
)
(if
@@ -10305,13 +10225,9 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load offset=20
- (get_local $10)
- )
- )
+ (tee_local $0
+ (i32.load offset=20
+ (get_local $10)
)
)
(if
@@ -10399,13 +10315,9 @@
(get_local $7)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load
- (i32.const 184)
- )
- )
+ (tee_local $0
+ (i32.load
+ (i32.const 184)
)
)
(block
@@ -11064,13 +10976,9 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load offset=16
- (get_local $24)
- )
- )
+ (tee_local $0
+ (i32.load offset=16
+ (get_local $24)
)
)
(block
@@ -11205,16 +11113,12 @@
(loop $while-in$24
(block $while-out$23
(if
- (i32.eqz
- (i32.eqz
- (tee_local $2
- (i32.load
- (tee_local $7
- (i32.add
- (get_local $8)
- (i32.const 20)
- )
- )
+ (tee_local $2
+ (i32.load
+ (tee_local $7
+ (i32.add
+ (get_local $8)
+ (i32.const 20)
)
)
)
@@ -11328,11 +11232,7 @@
)
(block $do-once$25
(if
- (i32.eqz
- (i32.eqz
- (get_local $1)
- )
- )
+ (get_local $1)
(block
(if
(i32.eq
@@ -11436,13 +11336,9 @@
(get_local $1)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $1
- (i32.load offset=16
- (get_local $13)
- )
- )
+ (tee_local $1
+ (i32.load offset=16
+ (get_local $13)
)
)
(if
@@ -11464,13 +11360,9 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load offset=20
- (get_local $13)
- )
- )
+ (tee_local $0
+ (i32.load offset=20
+ (get_local $13)
)
)
(if
@@ -12300,13 +12192,9 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load
- (i32.const 616)
- )
- )
+ (tee_local $0
+ (i32.load
+ (i32.const 616)
)
)
(if
@@ -12555,13 +12443,9 @@
)
(block
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load
- (i32.const 616)
- )
- )
+ (tee_local $0
+ (i32.load
+ (i32.const 616)
)
)
(br_if $do-once$39
@@ -13470,16 +13354,12 @@
(loop $while-in$62
(block $while-out$61
(if
- (i32.eqz
- (i32.eqz
- (tee_local $1
- (i32.load
- (tee_local $20
- (i32.add
- (get_local $2)
- (i32.const 20)
- )
- )
+ (tee_local $1
+ (i32.load
+ (tee_local $20
+ (i32.add
+ (get_local $2)
+ (i32.const 20)
)
)
)
@@ -13700,16 +13580,12 @@
(get_local $0)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load
- (tee_local $2
- (i32.add
- (get_local $3)
- (i32.const 16)
- )
- )
+ (tee_local $0
+ (i32.load
+ (tee_local $2
+ (i32.add
+ (get_local $3)
+ (i32.const 16)
)
)
)
@@ -15596,16 +15472,12 @@
(loop $while-in$5
(block $while-out$4
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load
- (tee_local $13
- (i32.add
- (get_local $2)
- (i32.const 20)
- )
- )
+ (tee_local $0
+ (i32.load
+ (tee_local $13
+ (i32.add
+ (get_local $2)
+ (i32.const 20)
)
)
)
@@ -15837,16 +15709,12 @@
(get_local $8)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $1
- (i32.load
- (tee_local $2
- (i32.add
- (get_local $4)
- (i32.const 16)
- )
- )
+ (tee_local $1
+ (i32.load
+ (tee_local $2
+ (i32.add
+ (get_local $4)
+ (i32.const 16)
)
)
)
@@ -16271,16 +16139,12 @@
(loop $while-in$13
(block $while-out$12
(if
- (i32.eqz
- (i32.eqz
- (tee_local $1
- (i32.load
- (tee_local $7
- (i32.add
- (get_local $2)
- (i32.const 20)
- )
- )
+ (tee_local $1
+ (i32.load
+ (tee_local $7
+ (i32.add
+ (get_local $2)
+ (i32.const 20)
)
)
)
@@ -16397,11 +16261,7 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (get_local $0)
- )
- )
+ (get_local $0)
(block
(if
(i32.eq
@@ -16505,16 +16365,12 @@
(get_local $0)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load
- (tee_local $2
- (i32.add
- (get_local $9)
- (i32.const 16)
- )
- )
+ (tee_local $0
+ (i32.load
+ (tee_local $2
+ (i32.add
+ (get_local $9)
+ (i32.const 16)
)
)
)
@@ -16538,13 +16394,9 @@
)
)
(if
- (i32.eqz
- (i32.eqz
- (tee_local $0
- (i32.load offset=4
- (get_local $2)
- )
- )
+ (tee_local $0
+ (i32.load offset=4
+ (get_local $2)
)
)
(if
diff --git a/test/passes/optimize-instructions.txt b/test/passes/optimize-instructions.txt
index 8ac9ea6fd..850c94c28 100644
--- a/test/passes/optimize-instructions.txt
+++ b/test/passes/optimize-instructions.txt
@@ -181,5 +181,9 @@
(i32.const 0)
)
)
+ (if
+ (i32.const 123)
+ (nop)
+ )
)
)
diff --git a/test/passes/optimize-instructions.wast b/test/passes/optimize-instructions.wast
index a9296c3cc..8265a4f70 100644
--- a/test/passes/optimize-instructions.wast
+++ b/test/passes/optimize-instructions.wast
@@ -210,5 +210,13 @@
(i32.const 0)
)
)
+ (if
+ (i32.eqz
+ (i32.eqz
+ (i32.const 123)
+ )
+ )
+ (nop)
+ )
)
)