diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp index 6f20cfd63af..64c68f2354e 100644 --- a/src/passes/RemoveUnusedBrs.cpp +++ b/src/passes/RemoveUnusedBrs.cpp @@ -24,6 +24,8 @@ #include "ir/effects.h" #include "ir/gc-type-utils.h" #include "ir/literal-utils.h" +#include "ir/localize.h" +#include "ir/properties.h" #include "ir/utils.h" #include "parsing.h" #include "pass.h" @@ -1881,6 +1883,36 @@ struct RemoveUnusedBrs : public WalkerPass> { start = end; } } + + void visitBreak(Break* curr) { + if (!curr->condition) { + return; + } + auto* value = Properties::getFallthrough( + curr->condition, passOptions, *getModule()); + // Optimize if condition's fallthrough is a constant. + if (auto* c = value->dynCast()) { + ChildLocalizer localizer( + curr, getFunction(), *getModule(), passOptions); + auto* block = localizer.getChildrenReplacement(); + if (c->value.geti32()) { + // the branch is always taken, make it unconditional + curr->condition = nullptr; + curr->type = Type::unreachable; + block->list.push_back(curr); + block->finalize(); + // The type changed, so refinalize. + refinalize = true; + } else { + // the branch is never taken, allow control flow to fall through + if (curr->value) { + block->list.push_back(curr->value); + block->finalize(); + } + } + replaceCurrent(block); + } + } }; FinalOptimizer finalOptimizer(getPassOptions()); finalOptimizer.setModule(getModule()); diff --git a/test/lit/passes/remove-unused-brs.wast b/test/lit/passes/remove-unused-brs.wast index ed7fd168148..da8c61cc941 100644 --- a/test/lit/passes/remove-unused-brs.wast +++ b/test/lit/passes/remove-unused-brs.wast @@ -5,7 +5,7 @@ (module ;; Regression test in which we need to calculate a proper LUB. - ;; CHECK: (func $selectify-fresh-lub (type $4) (param $x i32) (result anyref) + ;; CHECK: (func $selectify-fresh-lub (type $5) (param $x i32) (result anyref) ;; CHECK-NEXT: (select (result i31ref) ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: (ref.i31 @@ -340,6 +340,106 @@ ) ) + ;; CHECK: (func $restructure-br_if-constant-branch-1 (type $3) (param $x i32) + ;; CHECK-NEXT: (local $1 i32) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (block $x (result i32) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (local.set $1 + ;; CHECK-NEXT: (local.tee $x + ;; CHECK-NEXT: (i32.const 42) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br $x + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.const 20) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (block $x0 (result i32) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (block (result i32) + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.const 20) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $restructure-br_if-constant-branch-1 (param $x i32) + ;; We can see a nonzero constant falls through the tee, so this br always happens. + (drop + (block $x (result i32) + (drop + (br_if $x + (i32.const 10) + (local.tee $x + (i32.const 42) + ) + ) + ) + (i32.const 20) + ) + ) + ;; We can see the zero condition, so just let the control flow fall through. + (drop + (block $x (result i32) + (drop + (br_if $x + (i32.const 10) + (i32.const 0) + ) + ) + (i32.const 20) + ) + ) + ) + ;; CHECK: (func $restructure-br_if-constant-branch-2 (type $3) (param $x i32) + ;; CHECK-NEXT: (local $1 i32) + ;; CHECK-NEXT: (local $2 i32) + ;; CHECK-NEXT: (block $x + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (local.set $1 + ;; CHECK-NEXT: (local.tee $x + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block $x0 + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (local.set $2 + ;; CHECK-NEXT: (local.tee $x + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $restructure-br_if-constant-branch-2 (param $x i32) + ;; as before, but now there is no value. + (block $x + (br_if $x + (local.tee $x + (i32.const 1) + ) + ) + ) + (block $x + (br_if $x + (local.tee $x + (i32.const 0) + ) + ) + ) + ) + + ;; CHECK: (func $restructure-br_if-value-redundant-in-block-tail-1 (type $2) (result i32) ;; CHECK-NEXT: (block $parent (result i32) ;; CHECK-NEXT: (call $nothing) @@ -473,7 +573,7 @@ ;; CHECK-NEXT: (br_if $block ;; CHECK-NEXT: (local.get $temp) ;; CHECK-NEXT: (local.tee $temp - ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: (local.get $temp) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -489,7 +589,7 @@ (br_if $block (local.get $temp) (local.tee $temp - (i32.const 1) + (local.get $temp) ) ) ) @@ -498,8 +598,9 @@ ) ;; CHECK: (func $restructure-select-no-multivalue (type $1) + ;; CHECK-NEXT: (local $x i32) ;; CHECK-NEXT: (tuple.drop 2 - ;; CHECK-NEXT: (block $block (type $3) (result i32 i32) + ;; CHECK-NEXT: (block $block (type $4) (result i32 i32) ;; CHECK-NEXT: (tuple.drop 2 ;; CHECK-NEXT: (br_if $block ;; CHECK-NEXT: (tuple.make 2 @@ -508,7 +609,7 @@ ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (i32.const 3) + ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (tuple.make 2 @@ -519,6 +620,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $restructure-select-no-multivalue + (local $x i32) (tuple.drop 2 (block $block (result i32 i32) (tuple.drop 2 @@ -533,7 +635,7 @@ (i32.const 2) ) ) - (i32.const 3) + (local.get $x) ) ) (tuple.make 2 diff --git a/test/lit/passes/remove-unused-brs_all-features.wast b/test/lit/passes/remove-unused-brs_all-features.wast index e2d89a5ead5..87c1b2ae197 100644 --- a/test/lit/passes/remove-unused-brs_all-features.wast +++ b/test/lit/passes/remove-unused-brs_all-features.wast @@ -64,9 +64,10 @@ ) ;; CHECK: (func $test-prefinalize (type $4) (result f64) + ;; CHECK-NEXT: (local $x i32) ;; CHECK-NEXT: (loop $loop (result f64) ;; CHECK-NEXT: (if (result f64) - ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (f64.const 0) ;; CHECK-NEXT: ) @@ -85,12 +86,13 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $test-prefinalize (result f64) + (local $x i32) (loop $loop (result f64) (block $block (result f64) (drop (br_if $block (f64.const 0) - (i32.const 1) + (local.get $x) ) ) (if diff --git a/test/passes/remove-unused-brs_enable-multivalue.txt b/test/passes/remove-unused-brs_enable-multivalue.txt index a20f2905bf0..321b061e524 100644 --- a/test/passes/remove-unused-brs_enable-multivalue.txt +++ b/test/passes/remove-unused-brs_enable-multivalue.txt @@ -63,7 +63,7 @@ (func $b6 (param $i1 i32) (block $topmost (br_if $topmost - (i32.const 1) + (local.get $i1) ) ) ) @@ -74,7 +74,7 @@ (i32.const 0) ) (br_if $topmost - (i32.const 1) + (local.get $i1) ) ) ) @@ -83,7 +83,7 @@ (block $topmost (block $inner (br_if $topmost - (i32.const 1) + (local.get $i1) ) ) ) @@ -92,7 +92,7 @@ (block $topmost (block $inner (br_if $topmost - (i32.const 1) + (local.get $i1) ) ) ) @@ -105,7 +105,7 @@ (i32.const 0) ) (br_if $topmost - (i32.const 1) + (local.get $i1) ) ) ) @@ -119,7 +119,7 @@ (i32.const 0) ) (br_if $topmost - (i32.const 1) + (local.get $i1) ) ) ) @@ -157,6 +157,7 @@ ) ) (func $b13 (result i32) + (local $x i32) (block $topmost (result i32) (if (i32.const 1) @@ -167,8 +168,8 @@ ) (drop (br_if $topmost - (i32.const 1) - (i32.const 1) + (local.get $x) + (local.get $x) ) ) ) @@ -224,9 +225,10 @@ ) ) (func $b15 + (local $x i32) (block $topmost (br_if $topmost - (i32.const 17) + (local.get $x) ) ) ) @@ -502,6 +504,7 @@ ) ) (func $loops + (local $x i32) (loop $in (block $out (br_if $in @@ -517,14 +520,14 @@ (loop (block $out0 (br_if $out0 - (i32.const 0) + (local.get $x) ) ) ) (loop $in1 (block $out1 (br_if $out1 - (i32.const 0) + (local.get $x) ) ) ) @@ -537,13 +540,13 @@ (loop $in4 (if (i32.eqz - (i32.const 0) + (local.get $x) ) (then (block $out3 (nop) (br_if $in4 - (i32.const 1) + (local.get $x) ) ) ) @@ -552,7 +555,7 @@ (loop $in5 (block $out4 (br_if $in5 - (i32.const 0) + (local.get $x) ) ) ) @@ -764,7 +767,7 @@ (loop $in19 (block $out18 (drop - (i32.const 0) + (local.get $x) ) (br $in19) ) @@ -772,10 +775,10 @@ (loop $in-not (block $out-not (br_if $out-not - (i32.const -1) + (local.get $x) ) (br_if $out-not - (i32.const 0) + (local.get $x) ) (call $loops) (br $in-not) @@ -833,16 +836,17 @@ ) ) (func $threading + (local $x i32) (drop (block $value-out (result i32) (block $value-in (result i32) (block $out (block $in (br_if $out - (i32.const 1) + (local.get $x) ) (br_if $out - (i32.const 2) + (local.get $x) ) (br $value-in (i32.const 3) @@ -858,7 +862,7 @@ (block $stack3 (block $stack4 (br_if $stack1 - (i32.const 1) + (local.get $x) ) (unreachable) ) @@ -884,7 +888,7 @@ ) (else (br_if $leave - (i32.const 1) + (local.get $x) ) ) ) @@ -905,7 +909,7 @@ (local.get $x) (then (br_if $leave - (i32.const 1) + (local.get $x) ) ) (else @@ -993,9 +997,10 @@ ) ) (func $iffify + (local $x i32) (if (i32.eqz - (i32.const 0) + (local.get $x) ) (then (block $yes @@ -1011,7 +1016,7 @@ ) (block $no (br_if $no - (i32.const 0) + (local.get $x) ) (drop (i32.const 1) @@ -1023,7 +1028,7 @@ ) (block $no2 (br_if $no2 - (i32.const 0) + (local.get $x) ) ) (block $no3 @@ -1038,7 +1043,7 @@ (block $no5 (block $no4 (br_if $no5 - (i32.const 0) + (local.get $x) ) (drop (i32.const 1) @@ -1095,7 +1100,7 @@ (block $label$0 (result i32) (block $label$1 (br_if $label$1 - (i32.const 607395945) + (local.get $1) ) (br_if $label$1 (i32.load offset=3 align=1 @@ -1109,7 +1114,7 @@ (i32.const 1628075109) ) ) - (i32.const 1764950569) + (local.get $1) ) (f32.const 1.1910939690100655e-32) (i32.const 1628057906) @@ -1924,9 +1929,10 @@ ) ) (func $same-target-br_if-and-br + (local $x i32) (block $x (drop - (i32.const 0) + (local.get $x) ) (br $x) (unreachable) @@ -2312,9 +2318,10 @@ ) ) (func $if-block-br + (local $x i32) (block $label (br_if $label - (i32.const 1) + (local.get $x) ) ) ) @@ -2531,6 +2538,7 @@ ) ) (func $refinalize-need-br-value (result i32) + (local $x i32) (loop $label$3 (result i32) (block $label$6 (result i32) (block $label$10 @@ -2539,7 +2547,7 @@ (br_if $label$3 (block $label$530 (result i32) (br_if $label$503 - (i32.const 0) + (local.get $x) ) (i32.const 0) ) @@ -2898,7 +2906,7 @@ (then (br_if $label$1 (local.tee $0 - (i32.const -7) + (local.get $0) ) ) ) diff --git a/test/passes/remove-unused-brs_enable-multivalue.wast b/test/passes/remove-unused-brs_enable-multivalue.wast index 0deff0db881..acbd3781ab9 100644 --- a/test/passes/remove-unused-brs_enable-multivalue.wast +++ b/test/passes/remove-unused-brs_enable-multivalue.wast @@ -59,7 +59,7 @@ (func $b6 (type $0) (param $i1 i32) (block $topmost (br_if $topmost - (i32.const 1) + (local.get $i1) ) ) ) @@ -70,7 +70,7 @@ (i32.const 0) ) (br_if $topmost - (i32.const 1) + (local.get $i1) ) ) ) @@ -79,7 +79,7 @@ (block $topmost (block $inner (br_if $topmost - (i32.const 1) + (local.get $i1) ) ) ) @@ -88,7 +88,7 @@ (block $topmost (block $inner (br_if $topmost - (i32.const 1) + (local.get $i1) ) ) ) @@ -101,7 +101,7 @@ (i32.const 0) ) (br_if $topmost - (i32.const 1) + (local.get $i1) ) ) ) @@ -115,7 +115,7 @@ (i32.const 0) ) (br_if $inner - (i32.const 1) + (local.get $i1) ) ) ) @@ -155,6 +155,7 @@ ) ) (func $b13 (type $2) (result i32) + (local $x i32) (block $topmost (result i32) (if (i32.const 1) @@ -165,8 +166,8 @@ ) (drop (br_if $topmost - (i32.const 1) - (i32.const 1) + (local.get $x) + (local.get $x) ) ) ) @@ -226,9 +227,10 @@ ) ) (func $b15 (type $1) + (local $x i32) (block $topmost (if - (i32.const 17) + (local.get $x) (then (br $topmost) ) @@ -538,6 +540,7 @@ ) ) (func $loops + (local $x i32) (loop $in (block $out (if (i32.const 0) (then (br $out))) @@ -549,13 +552,13 @@ ) (loop (block $out - (if (i32.const 0) (then (br $out))) + (if (local.get $x) (then (br $out))) (br $out) ) ) (loop $in (block $out - (if (i32.const 0) (then (br $out))) + (if (local.get $x) (then (br $out))) (br $out) ) ) @@ -565,13 +568,13 @@ ) (loop $in (block $out - (if (i32.const 0) (then (br $out))) - (br_if $in (i32.const 1)) + (if (local.get $x) (then (br $out))) + (br_if $in (local.get $x)) ) ) (loop $in (block $out - (if (i32.const 0) (then (br $in))) + (if (local.get $x) (then (br $in))) (br $out) ) ) @@ -755,14 +758,14 @@ ) (loop $in (block $out - (br_if $in (i32.const 0)) + (br_if $in (local.get $x)) (br $in) ) ) (loop $in-not ;; do NOT if-ify, the block can't be removed (block $out-not - (br_if $out-not (i32.const -1)) - (br_if $out-not (i32.const 0)) + (br_if $out-not (local.get $x)) + (br_if $out-not (local.get $x)) (call $loops) (br $in-not) ) @@ -790,17 +793,18 @@ ) ) (func $threading + (local $x i32) (drop (block $value-out (result i32) (block $value-in (result i32) (block $out (block $in - (if (i32.const 1) + (if (local.get $x) (then (br $in) ) ) - (br_if $in (i32.const 2)) + (br_if $in (local.get $x)) (br $value-in (i32.const 3)) ) (br $out) @@ -813,7 +817,7 @@ (block $stack2 (block $stack3 (block $stack4 - (if (i32.const 1) + (if (local.get $x) (then (br $stack4) ) @@ -842,7 +846,7 @@ ) ) (else - (br_if $leave (i32.const 1)) + (br_if $leave (local.get $x)) ) ) (unreachable) @@ -858,7 +862,7 @@ (if (local.get $x) (then - (br_if $leave (i32.const 1)) + (br_if $leave (local.get $x)) ) (else (br $out @@ -935,16 +939,17 @@ ) ) (func $iffify + (local $x i32) (block $yes (br_if $yes - (i32.const 0) + (local.get $x) ) (drop (i32.const 1)) (drop (i32.const 2)) ) (block $no (br_if $no - (i32.const 0) + (local.get $x) ) (drop (i32.const 1)) (br $no) @@ -952,7 +957,7 @@ ) (block $no2 (br_if $no2 - (i32.const 0) + (local.get $x) ) ) (block $no3 @@ -963,7 +968,7 @@ (block $no5 (block $no4 (br_if $no5 - (i32.const 0) + (local.get $x) ) (drop (i32.const 1)) (drop (i32.const 2)) @@ -1011,7 +1016,7 @@ (block $label$0 (result i32) (block $label$1 ;; this block has no taken brs, but we can't remove it without removing them first (br_if $label$1 - (i32.const 607395945) + (local.get $1) ) (br_if $label$1 (i32.load16_s offset=3 align=1 @@ -1025,7 +1030,7 @@ (i32.const 1628075109) ) ) - (i32.const 1764950569) + (local.get $1) ) (f32.const 1.1910939690100655e-32) (i32.const 1628057906) @@ -1615,9 +1620,10 @@ ) ) (func $same-target-br_if-and-br + (local $x i32) (block $x (br_if $x - (i32.const 0) + (local.get $x) ) (br $x) (unreachable) @@ -1943,9 +1949,10 @@ ) ) (func $if-block-br + (local $x i32) (block $label (if - (i32.const 1) + (local.get $x) (then (br $label) ) @@ -2160,6 +2167,7 @@ ) ) (func $refinalize-need-br-value (result i32) + (local $x i32) (loop $label$3 (result i32) (block $label$6 (result i32) (block $label$10 @@ -2168,7 +2176,7 @@ (br_if $label$3 (block $label$530 (result i32) (br_if $label$503 ;; while this br does not send a value - (i32.const 0) + (local.get $x) ) (i32.const 0) ) @@ -2569,7 +2577,7 @@ (then (br_if $label$1 (local.tee $0 ;; but here it is *not* ok - (i32.const -7) + (local.get $0) ) ) ) diff --git a/test/passes/remove-unused-brs_shrink-level=1.txt b/test/passes/remove-unused-brs_shrink-level=1.txt index 24696cb8355..127f30508d7 100644 --- a/test/passes/remove-unused-brs_shrink-level=1.txt +++ b/test/passes/remove-unused-brs_shrink-level=1.txt @@ -53,28 +53,29 @@ (i32.const 0) ) (func $join-br_ifs + (local $x i32) (block $out (br_if $out (i32.or - (i32.const 1) - (i32.const 2) + (local.get $x) + (local.get $x) ) ) (nop) (br_if $out - (i32.const 3) + (local.get $x) ) ) (block $out2 (block $out3 (br_if $out2 - (i32.const 1) + (local.get $x) ) (br_if $out3 - (i32.const 2) + (local.get $x) ) (br_if $out2 - (i32.const 3) + (local.get $x) ) ) (unreachable) @@ -82,12 +83,12 @@ (block $out4 (block $out5 (br_if $out4 - (i32.const 1) + (local.get $x) ) (br_if $out5 (i32.or - (i32.const 2) - (i32.const 3) + (local.get $x) + (local.get $x) ) ) (nop) @@ -98,13 +99,13 @@ (block $out7 (br_if $out6 (i32.or - (i32.const 1) - (i32.const 2) + (local.get $x) + (local.get $x) ) ) (nop) (br_if $out7 - (i32.const 3) + (local.get $x) ) ) (unreachable) @@ -113,7 +114,7 @@ (i32.eqz (i32.or (call $b14) - (i32.const 0) + (local.get $x) ) ) (then @@ -125,7 +126,7 @@ ) (block $out80 (br_if $out80 - (i32.const 1) + (local.get $x) ) (br_if $out80 (call $b14) @@ -149,19 +150,21 @@ ) ) (func $br-if-unreachable-pair + (local $x i32) (block $label$14 (br_if $label$14 (unreachable) ) (br_if $label$14 - (i32.const 0) + (local.get $x) ) ) ) (func $br-if-unreachable-pair2 + (local $x i32) (block $label$14 (br_if $label$14 - (i32.const 0) + (local.get $x) ) (br_if $label$14 (unreachable) diff --git a/test/passes/remove-unused-brs_shrink-level=1.wast b/test/passes/remove-unused-brs_shrink-level=1.wast index ce141c43003..00d29376b06 100644 --- a/test/passes/remove-unused-brs_shrink-level=1.wast +++ b/test/passes/remove-unused-brs_shrink-level=1.wast @@ -55,41 +55,42 @@ (i32.const 0) ) (func $join-br_ifs + (local $x i32) (block $out - (br_if $out (i32.const 1)) - (br_if $out (i32.const 2)) - (br_if $out (i32.const 3)) + (br_if $out (local.get $x)) + (br_if $out (local.get $x)) + (br_if $out (local.get $x)) ) (block $out2 (block $out3 - (br_if $out2 (i32.const 1)) - (br_if $out3 (i32.const 2)) - (br_if $out2 (i32.const 3)) + (br_if $out2 (local.get $x)) + (br_if $out3 (local.get $x)) + (br_if $out2 (local.get $x)) ) (unreachable) ) (block $out4 (block $out5 - (br_if $out4 (i32.const 1)) - (br_if $out5 (i32.const 2)) - (br_if $out5 (i32.const 3)) + (br_if $out4 (local.get $x)) + (br_if $out5 (local.get $x)) + (br_if $out5 (local.get $x)) ) (unreachable) ) (block $out6 (block $out7 - (br_if $out6 (i32.const 1)) - (br_if $out6 (i32.const 2)) - (br_if $out7 (i32.const 3)) + (br_if $out6 (local.get $x)) + (br_if $out6 (local.get $x)) + (br_if $out7 (local.get $x)) ) (unreachable) ) (block $out8 (br_if $out8 (call $b14)) ;; side effect - (br_if $out8 (i32.const 0)) + (br_if $out8 (local.get $x)) ) (block $out8 - (br_if $out8 (i32.const 1)) + (br_if $out8 (local.get $x)) (br_if $out8 (call $b14)) ;; side effect ) ) @@ -110,19 +111,21 @@ ) ) (func $br-if-unreachable-pair + (local $x i32) (block $label$14 (br_if $label$14 (unreachable) ) (br_if $label$14 - (i32.const 0) + (local.get $x) ) ) ) (func $br-if-unreachable-pair2 + (local $x i32) (block $label$14 (br_if $label$14 - (i32.const 0) + (local.get $x) ) (br_if $label$14 (unreachable) @@ -190,4 +193,3 @@ (return (i32.const 3)) ) ) - diff --git a/test/passes/remove-unused-brs_shrink-level=1_ignore-implicit-traps.txt b/test/passes/remove-unused-brs_shrink-level=1_ignore-implicit-traps.txt index 82f76d359c7..461f5bc194b 100644 --- a/test/passes/remove-unused-brs_shrink-level=1_ignore-implicit-traps.txt +++ b/test/passes/remove-unused-brs_shrink-level=1_ignore-implicit-traps.txt @@ -45,28 +45,29 @@ (i32.const 0) ) (func $join-br_ifs + (local $x i32) (block $out (br_if $out (i32.or - (i32.const 1) - (i32.const 2) + (local.get $x) + (local.get $x) ) ) (nop) (br_if $out - (i32.const 3) + (local.get $x) ) ) (block $out2 (block $out3 (br_if $out2 - (i32.const 1) + (local.get $x) ) (br_if $out3 - (i32.const 2) + (local.get $x) ) (br_if $out2 - (i32.const 3) + (local.get $x) ) ) (unreachable) @@ -74,12 +75,12 @@ (block $out4 (block $out5 (br_if $out4 - (i32.const 1) + (local.get $x) ) (br_if $out5 (i32.or - (i32.const 2) - (i32.const 3) + (local.get $x) + (local.get $x) ) ) (nop) @@ -90,13 +91,13 @@ (block $out7 (br_if $out6 (i32.or - (i32.const 1) - (i32.const 2) + (local.get $x) + (local.get $x) ) ) (nop) (br_if $out7 - (i32.const 3) + (local.get $x) ) ) (unreachable) @@ -105,7 +106,7 @@ (i32.eqz (i32.or (call $b14) - (i32.const 0) + (local.get $x) ) ) (then @@ -117,7 +118,7 @@ ) (block $out80 (br_if $out80 - (i32.const 1) + (local.get $x) ) (br_if $out80 (call $b14) diff --git a/test/passes/remove-unused-brs_shrink-level=1_ignore-implicit-traps.wast b/test/passes/remove-unused-brs_shrink-level=1_ignore-implicit-traps.wast index 4f15dc9c020..b93cd89925e 100644 --- a/test/passes/remove-unused-brs_shrink-level=1_ignore-implicit-traps.wast +++ b/test/passes/remove-unused-brs_shrink-level=1_ignore-implicit-traps.wast @@ -55,41 +55,42 @@ (i32.const 0) ) (func $join-br_ifs + (local $x i32) (block $out - (br_if $out (i32.const 1)) - (br_if $out (i32.const 2)) - (br_if $out (i32.const 3)) + (br_if $out (local.get $x)) + (br_if $out (local.get $x)) + (br_if $out (local.get $x)) ) (block $out2 (block $out3 - (br_if $out2 (i32.const 1)) - (br_if $out3 (i32.const 2)) - (br_if $out2 (i32.const 3)) + (br_if $out2 (local.get $x)) + (br_if $out3 (local.get $x)) + (br_if $out2 (local.get $x)) ) (unreachable) ) (block $out4 (block $out5 - (br_if $out4 (i32.const 1)) - (br_if $out5 (i32.const 2)) - (br_if $out5 (i32.const 3)) + (br_if $out4 (local.get $x)) + (br_if $out5 (local.get $x)) + (br_if $out5 (local.get $x)) ) (unreachable) ) (block $out6 (block $out7 - (br_if $out6 (i32.const 1)) - (br_if $out6 (i32.const 2)) - (br_if $out7 (i32.const 3)) + (br_if $out6 (local.get $x)) + (br_if $out6 (local.get $x)) + (br_if $out7 (local.get $x)) ) (unreachable) ) (block $out8 (br_if $out8 (call $b14)) ;; side effect - (br_if $out8 (i32.const 0)) + (br_if $out8 (local.get $x)) ) (block $out8 - (br_if $out8 (i32.const 1)) + (br_if $out8 (local.get $x)) (br_if $out8 (call $b14)) ;; side effect ) )