summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/passes/OptimizeInstructions.cpp2
-rw-r--r--test/passes/O.bin.txt13
-rw-r--r--test/passes/optimize-instructions_enable-threads.txt16
-rw-r--r--test/passes/optimize-instructions_enable-threads.wast18
4 files changed, 42 insertions, 7 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp
index 4478a7bdd..729a42ada 100644
--- a/src/passes/OptimizeInstructions.cpp
+++ b/src/passes/OptimizeInstructions.cpp
@@ -1312,6 +1312,8 @@ private:
!EffectAnalyzer(getPassOptions(), binary->left)
.hasSideEffects()) {
return binary->right;
+ } else if (binary->op == EqInt64) {
+ return Builder(*getModule()).makeUnary(EqZInt64, binary->left);
}
}
// operations on all 1s
diff --git a/test/passes/O.bin.txt b/test/passes/O.bin.txt
index 89a24046c..7af8de37e 100644
--- a/test/passes/O.bin.txt
+++ b/test/passes/O.bin.txt
@@ -7,9 +7,8 @@
(export "fac-opt" (func $4))
(func $0 (; 0 ;) (; has Stack IR ;) (type $0) (param $0 i64) (result i64)
(if (result i64)
- (i64.eq
+ (i64.eqz
(local.get $0)
- (i64.const 0)
)
(i64.const 1)
(i64.mul
@@ -25,9 +24,8 @@
)
(func $1 (; 1 ;) (; has Stack IR ;) (type $0) (param $0 i64) (result i64)
(if (result i64)
- (i64.eq
+ (i64.eqz
(local.get $0)
- (i64.const 0)
)
(i64.const 1)
(i64.mul
@@ -51,9 +49,10 @@
)
(loop $label$3
(if
- (i64.ne
- (local.get $0)
- (i64.const 0)
+ (i32.eqz
+ (i64.eqz
+ (local.get $0)
+ )
)
(block
(local.set $1
diff --git a/test/passes/optimize-instructions_enable-threads.txt b/test/passes/optimize-instructions_enable-threads.txt
index f54b6ae99..ef3122a89 100644
--- a/test/passes/optimize-instructions_enable-threads.txt
+++ b/test/passes/optimize-instructions_enable-threads.txt
@@ -196,6 +196,22 @@
(i32.const 0)
)
)
+ (drop
+ (i64.eqz
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.eq
+ (i64.const 0)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.eqz
+ (i64.const 0)
+ )
+ )
(if
(i32.const 123)
(nop)
diff --git a/test/passes/optimize-instructions_enable-threads.wast b/test/passes/optimize-instructions_enable-threads.wast
index dfcaea597..243cb79d7 100644
--- a/test/passes/optimize-instructions_enable-threads.wast
+++ b/test/passes/optimize-instructions_enable-threads.wast
@@ -212,6 +212,24 @@
(i32.const 0)
)
)
+ (drop
+ (i64.eq
+ (i64.const 100)
+ (i64.const 0)
+ )
+ )
+ (drop
+ (i64.eq
+ (i64.const 0)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.eq
+ (i64.const 0)
+ (i64.const 0)
+ )
+ )
(if
(i32.eqz
(i32.eqz