diff options
Diffstat (limited to 'test/passes/remove-unused-brs.wast')
-rw-r--r-- | test/passes/remove-unused-brs.wast | 319 |
1 files changed, 217 insertions, 102 deletions
diff --git a/test/passes/remove-unused-brs.wast b/test/passes/remove-unused-brs.wast index b7dc1cc25..f3d20f5e0 100644 --- a/test/passes/remove-unused-brs.wast +++ b/test/passes/remove-unused-brs.wast @@ -1,126 +1,172 @@ (module (memory 256 256) - (func $b0-yes (param $i1 i32) + (type $0 (func (param i32))) + (type $1 (func)) + (type $2 (func (result i32))) + (func $b0-yes (type $0) (param $i1 i32) (block $topmost (br $topmost) ) ) - (func $b1 (param $i1 i32) + (func $b1 (type $0) (param $i1 i32) (block $topmost - (br $topmost - (i32.const 0) + (block + (drop + (i32.const 0) + ) + (br $topmost) ) ) ) - (func $b2 (param $i1 i32) + (func $b2 (type $0) (param $i1 i32) (block $topmost (block $inner (br $topmost) ) ) ) - (func $b3-yes (param $i1 i32) + (func $b3-yes (type $0) (param $i1 i32) (block $topmost (block $inner (br $inner) ) ) ) - (func $b4 (param $i1 i32) + (func $b4 (type $0) (param $i1 i32) (block $topmost (block $inner - (br $topmost - (i32.const 0) + (block + (drop + (i32.const 0) + ) + (br $topmost) ) ) ) ) - (func $b5 (param $i1 i32) + (func $b5 (type $0) (param $i1 i32) (block $topmost (block $inner - (br $inner - (i32.const 0) + (block + (drop + (i32.const 0) + ) + (br $inner) ) ) ) ) - (func $b6 (param $i1 i32) - (block $topmost - (br_if $topmost (i32.const 1)) - ) - ) - (func $b7 (param $i1 i32) + (func $b6 (type $0) (param $i1 i32) (block $topmost (br_if $topmost - (i32.const 0) (i32.const 1) ) ) ) - (func $b8 (param $i1 i32) + (func $b7 (type $0) (param $i1 i32) (block $topmost - (block $inner - (br_if $topmost (i32.const 1)) + (block + (drop + (i32.const 0) + ) + (br_if $topmost + (i32.const 1) + ) ) ) ) - (func $b9 (param $i1 i32) + (func $b8 (type $0) (param $i1 i32) (block $topmost (block $inner - (br_if $topmost (i32.const 1)) + (br_if $topmost + (i32.const 1) + ) ) ) ) - (func $b10 (param $i1 i32) + (func $b9 (type $0) (param $i1 i32) (block $topmost (block $inner (br_if $topmost - (i32.const 0) (i32.const 1) ) ) ) ) - (func $b11 (param $i1 i32) + (func $b10 (type $0) (param $i1 i32) (block $topmost (block $inner - (br_if $inner - (i32.const 0) - (i32.const 1) + (block + (drop + (i32.const 0) + ) + (br_if $topmost + (i32.const 1) + ) ) ) ) ) - (func $b12-yes + (func $b11 (type $0) (param $i1 i32) (block $topmost - (if_else (i32.const 1) + (block $inner (block - (i32.const 12) - (br $topmost + (drop + (i32.const 0) + ) + (br_if $inner (i32.const 1) ) ) - (block - (i32.const 27) - (br $topmost - (i32.const 2) + ) + ) + ) + (func $b12-yes (type $1) + (block $topmost + (if + (i32.const 1) + (block $block1 + (drop + (i32.const 12) + ) + (block + (drop + (i32.const 1) + ) + (br $topmost) + ) + ) + (block $block3 + (drop + (i32.const 27) + ) + (block + (drop + (i32.const 2) + ) + (br $topmost) ) ) ) ) ) - (func $b13 (result i32) + (func $b13 (type $2) (result i32) (block $topmost - (if_else (i32.const 1) - (block - (i32.const 12) + (if + (i32.const 1) + (block $block1 + (drop + (i32.const 12) + ) (br_if $topmost (i32.const 1) (i32.const 1) ) ) - (block - (i32.const 27) + (block $block3 + (drop + (i32.const 27) + ) (br $topmost (i32.const 2) ) @@ -129,19 +175,20 @@ (i32.const 3) ) ) - (func $b14 (result i32) + (func $b14 (type $2) (result i32) (block $topmost - (if_else (i32.const 1) - (block + (if + (i32.const 1) + (block $block1 (i32.const 12) ) - (block + (block $block3 (i32.const 27) ) ) ) ) - (func $b15 + (func $b15 (type $1) (block $topmost (if (i32.const 17) @@ -149,15 +196,20 @@ ) ) ) - (func $b15 + (func $b15 (type $1) (block $topmost (if (i32.const 18) - (br $topmost (i32.const 0)) + (block + (drop + (i32.const 0) + ) + (br $topmost) + ) ) ) ) - (func $b16 + (func $b16 (type $1) (block $a (block $b (block $c @@ -186,14 +238,14 @@ (br $a) ) ) - (func $b17 + (func $b17 (type $1) (block $a (if (i32.const 0) - (block + (block $block1 (br $a) ) - (block + (block $block3 (br $a) ) ) @@ -201,8 +253,10 @@ (block $a (if (i32.const 0) - (i32.const 1) - (block + (drop + (i32.const 1) + ) + (block $block6 (br $a) ) ) @@ -210,131 +264,192 @@ (block $a (if (i32.const 0) - (block + (block $block8 (br $a) ) - (i32.const 1) + (drop + (i32.const 1) + ) ) ) (block $c (block $b (if (i32.const 0) - (block + (block $block11 (br $b) ) - (block + (block $block13 (br $c) ) ) ) ) ) - (func $ret-1 + (func $ret-1 (type $1) (return) ) - (func $ret-2 - (block - (block + (func $ret-2 (type $1) + (block $block0 + (block $block1 (return) ) ) ) - (func $ret-3 - (block + (func $ret-3 (type $1) + (block $block0 (if (i32.const 0) (return) - (block + (block $block3 (return) ) ) ) ) - (func $ret-value (result i32) - (block - (block - (return (i32.const 1)) + (func $ret-value (type $2) (result i32) + (block $block0 + (block $block1 + (return + (i32.const 1) + ) ) ) ) - (func $no-select-but-the-last + (func $no-select-but-the-last (type $1) (block $a (if (i32.const 0) - (i32.const 1) - (block - (br $a (i32.const 2)) - (i32.const 3) + (drop + (i32.const 1) + ) + (block $block2 + (block + (drop + (i32.const 2) + ) + (br $a) + ) + (drop + (i32.const 3) + ) ) ) (if (i32.const 0) - (block - (br $a (i32.const 2)) - (i32.const 3) + (block $block4 + (block + (drop + (i32.const 2) + ) + (br $a) + ) + (drop + (i32.const 3) + ) + ) + (drop + (i32.const 1) ) - (i32.const 1) ) (if - (block - (br $a (i32.const 2)) + (block $block6 + (block + (drop + (i32.const 2) + ) + (br $a) + ) (i32.const 3) ) - (i32.const 0) - (i32.const 1) + (drop + (i32.const 0) + ) + (drop + (i32.const 1) + ) ) - (if ;; brs to the inner $a's get removed, the it is selectifiable + (if (block $a - (br $a (i32.const 0)) + (br $a + (i32.const 0) + ) ) (block $a - (br $a (i32.const 1)) + (block + (drop + (i32.const 1) + ) + (br $a) + ) ) (block $a - (br $a (i32.const 2)) + (block + (drop + (i32.const 2) + ) + (br $a) + ) ) ) ) ) - (func $side-effects-and-order (result i32) + (func $side-effects-and-order (type $2) (result i32) (local $x i32) (block $do-once$0 (if (call $b13) - (br $do-once$0 - (i32.const 0) + (block + (drop + (i32.const 0) + ) + (br $do-once$0) ) ) - (i32.const 1) + (drop + (i32.const 1) + ) ) (block $do-once$0 (if (call $b13) - (br $do-once$0 - (call $b14) + (block + (drop + (call $b14) + ) + (br $do-once$0) ) ) - (i32.const 1) + (drop + (i32.const 1) + ) ) (block $do-once$0 (if (i32.const 0) - (br $do-once$0 - (call $b14) + (block + (drop + (call $b14) + ) + (br $do-once$0) ) ) - (i32.const 1) + (drop + (i32.const 1) + ) ) (block $do-once$0 (if - (set_local $x (i32.const 1)) + (tee_local $x + (i32.const 1) + ) (br $do-once$0 - (set_local $x (i32.const 2)) + (tee_local $x + (i32.const 2) + ) ) ) (i32.const 1) ) ) ) - |