summaryrefslogtreecommitdiff
path: root/test/lit/passes/merge-blocks.wast
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-10-10 08:40:24 -0700
committerGitHub <noreply@github.com>2024-10-10 08:40:24 -0700
commita8aa6602cdbedd04e69d362c01bbf378a44b395d (patch)
tree3cd354b15045a2bc69eca26892562947ea917f4e /test/lit/passes/merge-blocks.wast
parentdebd24681cb4764e75936dd74bc33c41899b8a23 (diff)
downloadbinaryen-a8aa6602cdbedd04e69d362c01bbf378a44b395d.tar.gz
binaryen-a8aa6602cdbedd04e69d362c01bbf378a44b395d.tar.bz2
binaryen-a8aa6602cdbedd04e69d362c01bbf378a44b395d.zip
ReFinalize in MergeBlocks so we can optimize unreachable instructions too (#6994)
In #6984 we optimized dropped blocks even if they had unreachable code. In #6988 that part was reverted, and blocks with unreachable code were ignored once more. However, I realized that the check was not actually for unreachable code, but for having an unreachable child, so it would miss things like this: (block (block .. (br $somewhere) ;; unreachable type, but no unreachable code ) ) But it is useful to merge such blocks: we don't need the inner block here. To fix this, just run ReFinalize if we change anything, which will propagate unreachability as needed. I think MergeBlocks was written before we had that utility, so it didn't use it... This is not only useful for itself but will unblock an EH optimization in a later PR, that has code in this form. It also simplifies the code by removing the hasUnreachableChild checks.
Diffstat (limited to 'test/lit/passes/merge-blocks.wast')
-rw-r--r--test/lit/passes/merge-blocks.wast9
1 files changed, 4 insertions, 5 deletions
diff --git a/test/lit/passes/merge-blocks.wast b/test/lit/passes/merge-blocks.wast
index 6fa1687b8..86181f7a4 100644
--- a/test/lit/passes/merge-blocks.wast
+++ b/test/lit/passes/merge-blocks.wast
@@ -405,12 +405,11 @@
)
;; CHECK: (func $toplevel (type $4)
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (block $label (result i32)
- ;; CHECK-NEXT: (br $label
- ;; CHECK-NEXT: (i32.const 42)
- ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (block $label
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (i32.const 42)
;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (br $label)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $toplevel