summaryrefslogtreecommitdiff
path: root/test/lit/passes/optimize-instructions.wast
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-04-23 16:09:35 -0700
committerGitHub <noreply@github.com>2021-04-23 16:09:35 -0700
commit3fe1823a59dc689d081a7a7e327639c20bf51bbc (patch)
treeff7b7840f4f1718864bffa6bc75e55f8ebf88cf6 /test/lit/passes/optimize-instructions.wast
parent8b66a9d40f55758b99b528d7adb371d275707c5e (diff)
downloadbinaryen-3fe1823a59dc689d081a7a7e327639c20bf51bbc.tar.gz
binaryen-3fe1823a59dc689d081a7a7e327639c20bf51bbc.tar.bz2
binaryen-3fe1823a59dc689d081a7a7e327639c20bf51bbc.zip
OptimizeInstructions: Do not change unreachability in if/select changes (#3840)
For example, (if (result i32) (local.get $x) (return (local.get $y) ) (return (local.get $z) ) ) If we move the returns outside we'd become unreachable, but we should not make such type changes in this pass (they are handled by DCE and Vacuum). (found by the fuzzer)
Diffstat (limited to 'test/lit/passes/optimize-instructions.wast')
-rw-r--r--test/lit/passes/optimize-instructions.wast50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/lit/passes/optimize-instructions.wast b/test/lit/passes/optimize-instructions.wast
index 058c030dd..5b5b44b57 100644
--- a/test/lit/passes/optimize-instructions.wast
+++ b/test/lit/passes/optimize-instructions.wast
@@ -12188,6 +12188,33 @@
)
)
)
+ ;; CHECK: (func $ternary-identical-arms-return-select (param $x i32) (param $y i32) (param $z i32) (result i32)
+ ;; CHECK-NEXT: (block $block
+ ;; CHECK-NEXT: (select
+ ;; CHECK-NEXT: (return
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (return
+ ;; CHECK-NEXT: (local.get $y)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (local.get $z)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $ternary-identical-arms-return-select (param $x i32) (param $y i32) (param $z i32) (result i32)
+ (block $block
+ ;; we cannot optimize a select currently as the return has side effects
+ (select
+ (return
+ (local.get $x)
+ )
+ (return
+ (local.get $y)
+ )
+ (local.get $z)
+ )
+ )
+ )
;; CHECK: (func $send-i32 (param $0 i32)
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: )
@@ -12212,4 +12239,27 @@
)
)
)
+ ;; CHECK: (func $if-dont-change-to-unreachable (param $x i32) (param $y i32) (param $z i32) (result i32)
+ ;; CHECK-NEXT: (if (result i32)
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: (return
+ ;; CHECK-NEXT: (local.get $y)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (return
+ ;; CHECK-NEXT: (local.get $z)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $if-dont-change-to-unreachable (param $x i32) (param $y i32) (param $z i32) (result i32)
+ ;; if we move the returns outside, we'd become unreachable; avoid that.
+ (if (result i32)
+ (local.get $x)
+ (return
+ (local.get $y)
+ )
+ (return
+ (local.get $z)
+ )
+ )
+ )
)