diff options
author | Alon Zakai <azakai@google.com> | 2021-04-22 13:47:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-22 13:47:21 -0700 |
commit | 23a26c75c6d737d6f97ed1048639b41e948fdd58 (patch) | |
tree | e3110280f6a774f64a43ce5e4694652a152955f1 /test/lit/passes/optimize-instructions.wast | |
parent | ba8955f80b58e9a18b675c399b39a547d96facc2 (diff) | |
download | binaryen-23a26c75c6d737d6f97ed1048639b41e948fdd58.tar.gz binaryen-23a26c75c6d737d6f97ed1048639b41e948fdd58.tar.bz2 binaryen-23a26c75c6d737d6f97ed1048639b41e948fdd58.zip |
OptimizeInstructions: Fix/ignore eqz hoisting of if with unreachable arm (#3835)
We tried to ignore unreachable code, but only checked the type of
the entire node. But an arm might be unreachable, and after moving
code around that requires more work to update the type. But such
cases are best left to DCE anyhow, so just check for any unreachability
and stop there.
Diffstat (limited to 'test/lit/passes/optimize-instructions.wast')
-rw-r--r-- | test/lit/passes/optimize-instructions.wast | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/lit/passes/optimize-instructions.wast b/test/lit/passes/optimize-instructions.wast index 3ed0b3115..fd2637373 100644 --- a/test/lit/passes/optimize-instructions.wast +++ b/test/lit/passes/optimize-instructions.wast @@ -11814,6 +11814,46 @@ ) ) ) + ;; CHECK: (func $ternary-no-unreachable-1 (param $x i32) (result i32) + ;; CHECK-NEXT: (if (result i32) + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: (i32.eqz + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $ternary-no-unreachable-1 (param $x i32) (result i32) + (if (result i32) + (local.get $x) + ;; one arm is an eqz, the other is 0 or 1, so we can put an eqz on the + ;; outside in theory, but we'd need to be careful with the unreachable + ;; type here. ignore this case, as DCE is the proper optimization anyhow. + (i32.eqz + (unreachable) + ) + (i32.const 0) + ) + ) + ;; CHECK: (func $ternary-no-unreachable-2 (param $x i32) (result i32) + ;; CHECK-NEXT: (if (result i32) + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: (i32.eqz + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $ternary-no-unreachable-2 (param $x i32) (result i32) + (if (result i32) + (local.get $x) + ;; as before, but flipped + (i32.const 0) + (i32.eqz + (unreachable) + ) + ) + ) ;; CHECK: (func $ternary-identical-arms (param $x i32) (param $y i32) (param $z i32) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (i32.eqz |