diff options
author | Thomas Lively <tlively@google.com> | 2024-01-04 14:25:18 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-04 14:25:18 -0800 |
commit | a58281ca114359cd6e65f5daaf086636aa18b0b0 (patch) | |
tree | ff98bd31d1c87b598027c2303b17855a44346515 /test/passes/precompute-propagate_all-features.wast | |
parent | 0ed42cf976ce9a3dfbe9cbb0885122e8fb6a377b (diff) | |
download | binaryen-a58281ca114359cd6e65f5daaf086636aa18b0b0.tar.gz binaryen-a58281ca114359cd6e65f5daaf086636aa18b0b0.tar.bz2 binaryen-a58281ca114359cd6e65f5daaf086636aa18b0b0.zip |
Require `then` and `else` with `if` (#6201)
We previously supported (and primarily used) a non-standard text format for
conditionals in which the condition, if-true expression, and if-false expression
were all simply s-expression children of the `if` expression. The standard text
format, however, requires the use of `then` and `else` forms to introduce the
if-true and if-false arms of the conditional. Update the legacy text parser to
require the standard format and update all tests to match. Update the printer to
print the standard format as well.
The .wast and .wat test inputs were mechanically updated with this script:
https://gist.github.com/tlively/85ae7f01f92f772241ec994c840ccbb1
Diffstat (limited to 'test/passes/precompute-propagate_all-features.wast')
-rw-r--r-- | test/passes/precompute-propagate_all-features.wast | 72 |
1 files changed, 50 insertions, 22 deletions
diff --git a/test/passes/precompute-propagate_all-features.wast b/test/passes/precompute-propagate_all-features.wast index 17a20417d..0460ad34a 100644 --- a/test/passes/precompute-propagate_all-features.wast +++ b/test/passes/precompute-propagate_all-features.wast @@ -8,38 +8,54 @@ (func $split (param $p i32) (local $x i32) (if (i32.const 1) - (local.set $x (i32.const 10)) + (then + (local.set $x (i32.const 10)) + ) ) (call $basic (i32.add (local.get $x) (local.get $x))) ) (func $split-but-join (param $p i32) (local $x i32) (if (i32.const 1) - (local.set $x (i32.const 10)) - (local.set $x (i32.const 10)) + (then + (local.set $x (i32.const 10)) + ) + (else + (local.set $x (i32.const 10)) + ) ) (call $basic (i32.add (local.get $x) (local.get $x))) ) (func $split-but-join-different (param $p i32) (local $x i32) (if (i32.const 1) - (local.set $x (i32.const 10)) - (local.set $x (i32.const 20)) + (then + (local.set $x (i32.const 10)) + ) + (else + (local.set $x (i32.const 20)) + ) ) (call $basic (i32.add (local.get $x) (local.get $x))) ) (func $split-but-join-different-b (param $p i32) (local $x i32) (if (i32.const 1) - (local.set $x (i32.const 10)) - (local.set $x (local.get $p)) + (then + (local.set $x (i32.const 10)) + ) + (else + (local.set $x (local.get $p)) + ) ) (call $basic (i32.add (local.get $x) (local.get $x))) ) (func $split-but-join-init0 (param $p i32) (local $x i32) (if (i32.const 1) - (local.set $x (i32.const 0)) + (then + (local.set $x (i32.const 0)) + ) ) (call $basic (i32.add (local.get $x) (local.get $x))) ) @@ -62,8 +78,12 @@ (local $y i32) (local.set $x (i32.const 10)) (if (i32.const 1) - (local.set $y (i32.const 11)) - (local.set $y (i32.add (local.get $x) (i32.const 1))) + (then + (local.set $y (i32.const 11)) + ) + (else + (local.set $y (i32.add (local.get $x) (i32.const 1))) + ) ) (local.set $y (i32.add (local.get $x) (local.get $y))) (local.get $y) @@ -73,8 +93,12 @@ (local $y i32) (local.set $x (i32.const 10)) (if (i32.const 1) - (local.set $y (i32.const 12)) ;; 12, not 11... - (local.set $y (i32.add (local.get $x) (i32.const 1))) + (then + (local.set $y (i32.const 12)) ;; 12, not 11... + ) + (else + (local.set $y (i32.add (local.get $x) (i32.const 1))) + ) ) (local.set $y (i32.add (local.get $x) (local.get $y))) (local.get $y) @@ -83,8 +107,8 @@ (local $x i32) (local $y i32) (loop $loop ;; we look like we depend on the other, but we don't actually - (local.set $x (if (result i32) (i32.const 1) (i32.const 0) (local.get $y))) - (local.set $y (if (result i32) (i32.const 1) (i32.const 0) (local.get $x))) + (local.set $x (if (result i32) (i32.const 1) (then (i32.const 0) )(else (local.get $y)))) + (local.set $y (if (result i32) (i32.const 1) (then (i32.const 0) )(else (local.get $x)))) (br $loop) ) ) @@ -92,8 +116,8 @@ (local $x i32) (local $y i32) (loop $loop ;; we look like we depend on the other, but we don't actually - (local.set $x (if (result i32) (i32.const 1) (i32.const 0) (local.get $y))) - (local.set $y (if (result i32) (i32.const 1) (i32.const 0) (local.get $x))) + (local.set $x (if (result i32) (i32.const 1) (then (i32.const 0) )(else (local.get $y)))) + (local.set $y (if (result i32) (i32.const 1) (then (i32.const 0) )(else (local.get $x)))) (call $deadloop2 (local.get $x)) (call $deadloop2 (local.get $y)) (br $loop) @@ -103,8 +127,8 @@ (local $x i32) (local $y i32) (loop $loop ;; we look like we depend on the other, but we don't actually - (local.set $x (if (result i32) (i32.const 1) (i32.const 0) (local.get $x))) - (local.set $y (if (result i32) (i32.const 1) (i32.const 0) (local.get $y))) + (local.set $x (if (result i32) (i32.const 1) (then (i32.const 0) )(else (local.get $x)))) + (local.set $y (if (result i32) (i32.const 1) (then (i32.const 0) )(else (local.get $y)))) (call $deadloop2 (local.get $x)) (call $deadloop2 (local.get $y)) (br $loop) @@ -147,14 +171,18 @@ ;; if lower down, but we do not do an additional cycle of ;; this pass automatically as such things are fairly rare, ;; so that opportunity remains unoptimized in this test. - (local.set $3 ;; this set is completely removed, allowing later opts - (i32.const 24) + (then + (local.set $3 ;; this set is completely removed, allowing later opts + (i32.const 24) + ) ) ) (if (local.get $3) - (local.set $2 - (i32.const 0) + (then + (local.set $2 + (i32.const 0) + ) ) ) (local.get $2) |