summaryrefslogtreecommitdiff
path: root/test/lit/passes/optimize-instructions-gc.wast
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-06-24 12:09:41 -0700
committerGitHub <noreply@github.com>2022-06-24 12:09:41 -0700
commitefea05006b4179db159d8850c33a4b54cf04d317 (patch)
treef0e0161924a1fcc7887e49fd5a88215932a1b3a6 /test/lit/passes/optimize-instructions-gc.wast
parent10523fa2468a21b0add13ccfda2d42888be72040 (diff)
downloadbinaryen-efea05006b4179db159d8850c33a4b54cf04d317.tar.gz
binaryen-efea05006b4179db159d8850c33a4b54cf04d317.tar.bz2
binaryen-efea05006b4179db159d8850c33a4b54cf04d317.zip
[Wasm GC] OptimizeInstructions: Optimize ref.eq on equal inputs with a tee (#4749)
(ref.eq (local.tee $x (..)) (local.get $x) ) That will definitely return 1. Before this PR the side effects of tee stopped us from optimizing.
Diffstat (limited to 'test/lit/passes/optimize-instructions-gc.wast')
-rw-r--r--test/lit/passes/optimize-instructions-gc.wast29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/lit/passes/optimize-instructions-gc.wast b/test/lit/passes/optimize-instructions-gc.wast
index 64213d930..2c6498ec3 100644
--- a/test/lit/passes/optimize-instructions-gc.wast
+++ b/test/lit/passes/optimize-instructions-gc.wast
@@ -979,6 +979,16 @@
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.const 1)
;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (block (result i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (local.tee $x
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; NOMNL: (func $ref-eq-corner-cases (type $eqref_=>_none) (param $x eqref)
;; NOMNL-NEXT: (drop
@@ -1006,6 +1016,16 @@
;; NOMNL-NEXT: (drop
;; NOMNL-NEXT: (i32.const 1)
;; NOMNL-NEXT: )
+ ;; NOMNL-NEXT: (drop
+ ;; NOMNL-NEXT: (block (result i32)
+ ;; NOMNL-NEXT: (drop
+ ;; NOMNL-NEXT: (local.tee $x
+ ;; NOMNL-NEXT: (local.get $x)
+ ;; NOMNL-NEXT: )
+ ;; NOMNL-NEXT: )
+ ;; NOMNL-NEXT: (i32.const 1)
+ ;; NOMNL-NEXT: )
+ ;; NOMNL-NEXT: )
;; NOMNL-NEXT: )
(func $ref-eq-corner-cases (param $x eqref)
;; side effects prevent optimization
@@ -1058,6 +1078,15 @@
)
)
)
+ ;; a tee does not prevent optimization, as we can fold the tee and the get.
+ (drop
+ (ref.eq
+ (local.tee $x
+ (local.get $x)
+ )
+ (local.get $x)
+ )
+ )
)
;; CHECK: (func $ref-eq-ref-cast (param $x eqref)