summaryrefslogtreecommitdiff
path: root/test/lit/passes/optimize-instructions.wast
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-08-24 11:40:43 -0700
committerGitHub <noreply@github.com>2022-08-24 11:40:43 -0700
commitd5e17e7bbe0901606b0892dfe3fca88d84bf6f82 (patch)
tree9112bc454efc207773140acb4a0b61bea3137c1b /test/lit/passes/optimize-instructions.wast
parentcee1c8681b3ae6bf5836999bd4df3d1d0997a138 (diff)
downloadbinaryen-d5e17e7bbe0901606b0892dfe3fca88d84bf6f82.tar.gz
binaryen-d5e17e7bbe0901606b0892dfe3fca88d84bf6f82.tar.bz2
binaryen-d5e17e7bbe0901606b0892dfe3fca88d84bf6f82.zip
[TNH Fuzzing] Fix some equality checks that ignored effects (#4951)
Fuzzing with TrapsNeverHappen found a bug, and then reading similar code I found another, where we check structural equality but ignored effects. Some things look equal but may have different values at runtime: (foo (call $x) (call $y) ) The arms are identical structurally but due to side effects may not be identical in value.
Diffstat (limited to 'test/lit/passes/optimize-instructions.wast')
-rw-r--r--test/lit/passes/optimize-instructions.wast19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/lit/passes/optimize-instructions.wast b/test/lit/passes/optimize-instructions.wast
index 336bb63ae..73e7fd286 100644
--- a/test/lit/passes/optimize-instructions.wast
+++ b/test/lit/passes/optimize-instructions.wast
@@ -5,6 +5,10 @@
(memory 0)
;; CHECK: (type $0 (func (param i32 i64)))
(type $0 (func (param i32 i64)))
+
+ ;; CHECK: (import "a" "b" (func $get-f64 (result f64)))
+ (import "a" "b" (func $get-f64 (result f64)))
+
;; CHECK: (func $and-and (param $i1 i32) (result i32)
;; CHECK-NEXT: (i32.and
;; CHECK-NEXT: (local.get $i1)
@@ -13238,6 +13242,14 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (f64.abs
+ ;; CHECK-NEXT: (f64.mul
+ ;; CHECK-NEXT: (call $get-f64)
+ ;; CHECK-NEXT: (call $get-f64)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
;; CHECK-NEXT: (f64.div
;; CHECK-NEXT: (local.get $x0)
;; CHECK-NEXT: (local.get $x0)
@@ -13378,6 +13390,13 @@
(local.get $y0)
)
))
+ ;; this one cannot be optimized as the runtime values may differ
+ (drop (f64.abs
+ (f64.mul
+ (call $get-f64)
+ (call $get-f64)
+ )
+ ))
;; abs(x / x) ==> x / x
(drop (f64.abs