summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-07-05 13:12:26 -0700
committerGitHub <noreply@github.com>2023-07-05 13:12:26 -0700
commitf963083cfb7ca42d76928f52889faf4aeaec54cf (patch)
tree3076145eb9281c320cd0d3fc526482c349195b75 /test
parentef7f98e50662374b17d88c149a2ba1c11f918e5c (diff)
downloadbinaryen-f963083cfb7ca42d76928f52889faf4aeaec54cf.tar.gz
binaryen-f963083cfb7ca42d76928f52889faf4aeaec54cf.tar.bz2
binaryen-f963083cfb7ca42d76928f52889faf4aeaec54cf.zip
OptimizeInstructions: Loop on fallthrough values in RefTest (#5797)
This parallels the code in RefCast. Previously we only looked at the type reaching us, but intermediate fallthrough values can let us optimize too. In particular, we were not optimizing (ref.test (local.tee ..)) if the tee was to a less-refined type.
Diffstat (limited to 'test')
-rw-r--r--test/lit/passes/optimize-instructions-gc.wast55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/lit/passes/optimize-instructions-gc.wast b/test/lit/passes/optimize-instructions-gc.wast
index c55ca8b05..c581c7e42 100644
--- a/test/lit/passes/optimize-instructions-gc.wast
+++ b/test/lit/passes/optimize-instructions-gc.wast
@@ -2426,6 +2426,61 @@
)
)
+ ;; CHECK: (func $ref.test-fallthrough (type $void)
+ ;; CHECK-NEXT: (local $A (ref $A))
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (ref.test $B
+ ;; CHECK-NEXT: (local.tee $A
+ ;; CHECK-NEXT: (struct.new $A
+ ;; CHECK-NEXT: (i32.const 10)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (block (result i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (local.tee $A
+ ;; CHECK-NEXT: (struct.new $B
+ ;; CHECK-NEXT: (i32.const 20)
+ ;; CHECK-NEXT: (i32.const 30)
+ ;; CHECK-NEXT: (f32.const 40.5)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $ref.test-fallthrough
+ (local $A (ref $A))
+ ;; The test will fail, but this pass does not have exact type info, so it
+ ;; thinks it can succeed and nothing happens here (GUFA can optimize this,
+ ;; however).
+ (drop
+ (ref.test $B
+ (local.tee $A
+ (struct.new $A
+ (i32.const 10)
+ )
+ )
+ )
+ )
+ ;; This test will succeed, even though we tee to the parent type in the
+ ;; middle.
+ (drop
+ (ref.test $B
+ (local.tee $A
+ (struct.new $B
+ (i32.const 20)
+ (i32.const 30)
+ (f32.const 40.50)
+ )
+ )
+ )
+ )
+ )
+
;; CHECK: (func $ref.test-then-optimizeAddedConstants (type $none_=>_i32) (result i32)
;; CHECK-NEXT: (i32.add
;; CHECK-NEXT: (block