diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/remove-unused-brs.txt | 43 | ||||
-rw-r--r-- | test/passes/remove-unused-brs.wast | 19 |
2 files changed, 50 insertions, 12 deletions
diff --git a/test/passes/remove-unused-brs.txt b/test/passes/remove-unused-brs.txt index 39a4d89f3..607b8ecb4 100644 --- a/test/passes/remove-unused-brs.txt +++ b/test/passes/remove-unused-brs.txt @@ -8,6 +8,7 @@ (type $6 (func (param i32) (result i64))) (type $7 (func (result i64))) (type $8 (func (result f32))) + (type $9 (func (param i32) (result f32))) (memory $0 256 256) (func $b0-yes (type $0) (param $i1 i32) (block $topmost @@ -483,11 +484,12 @@ ) (loop $in45 (block $out46 - (if - (i32.const 0) - (unreachable) + (br_if $in45 + (i32.eqz + (i32.const 0) + ) ) - (br $in45) + (unreachable) ) ) (loop $in48 @@ -1123,18 +1125,35 @@ ) (func $unreachable-return-loop-value (type $7) (result i64) (loop $loop - (br_if $loop - (i32.eqz - (i32.const 1) + (if + (i32.const 1) + (block $block + (br_if $block + (br $loop) + ) + (br $loop) ) ) - (block $block - (br_if $block - (br $loop) + (br $loop) + ) + ) + (func $obviously-flows-out-maybe (type $9) (param $var$0 i32) (result f32) + (block $label$1 (result f32) + (br $label$1 + (f32.const 1) + ) + (loop $label$5 + (if + (i32.const 11) + (block $label$8 + (br_if $label$8 + (unreachable) + ) + (br $label$5) + ) ) - (br $loop) + (br $label$5) ) ) - (unreachable) ) ) diff --git a/test/passes/remove-unused-brs.wast b/test/passes/remove-unused-brs.wast index 14b4abc4c..731a9f88f 100644 --- a/test/passes/remove-unused-brs.wast +++ b/test/passes/remove-unused-brs.wast @@ -1020,5 +1020,24 @@ (br $loop) ;; we 100% go back to the loop top, the loop is never exited. but opts move code around so that is not obvious anymore, and the loop becomes a nop, but the func has a return value ) ) + (func $obviously-flows-out-maybe (param $var$0 i32) (result f32) + (block $label$1 (result f32) + (br $label$1 + (f32.const 1) + ) + (loop $label$5 + (if + (i32.const 11) + (block $label$8 ;; this block is none - it has a break, even if not taken - and so looks like it might flow out, + (br_if $label$8 ;; and so we can't move it outside to be the end of the loop's block + (unreachable) + ) + (br $label$5) + ) + ) + (br $label$5) + ) + ) + ) ) |