diff options
-rw-r--r-- | src/passes/Vacuum.cpp | 6 | ||||
-rw-r--r-- | test/passes/vacuum.txt | 14 | ||||
-rw-r--r-- | test/passes/vacuum.wast | 18 |
3 files changed, 38 insertions, 0 deletions
diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index 40f4a6e59..0178a794d 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -232,6 +232,12 @@ struct Vacuum : public WalkerPass<PostWalker<Vacuum>> { replaceCurrent(child); return; } + // if the condition is unreachable, just return it + if (curr->condition->type == unreachable) { + replaceCurrent(curr->condition); + return; + } + // from here on, we can assume the condition executed if (curr->ifFalse) { if (curr->ifFalse->is<Nop>()) { curr->ifFalse = nullptr; diff --git a/test/passes/vacuum.txt b/test/passes/vacuum.txt index e07357296..7cee4edf1 100644 --- a/test/passes/vacuum.txt +++ b/test/passes/vacuum.txt @@ -273,4 +273,18 @@ ) ) ) + (func $unreachable-if-with-nop-arm-that-leaves-a-concrete-value-if-nop-is-removed (type $0) + (block $label$0 + (loop $label$1 + (br_if $label$0 + (i32.load8_s + (i32.const 1634541608) + ) + (loop $label$9 + (br $label$9) + ) + ) + ) + ) + ) ) diff --git a/test/passes/vacuum.wast b/test/passes/vacuum.wast index 77ffabd60..1885da09b 100644 --- a/test/passes/vacuum.wast +++ b/test/passes/vacuum.wast @@ -593,4 +593,22 @@ ) ) ) + (func $unreachable-if-with-nop-arm-that-leaves-a-concrete-value-if-nop-is-removed + (block $label$0 + (loop $label$1 + (if + (br_if $label$0 + (i32.load8_s + (i32.const 1634541608) + ) + (loop $label$9 + (br $label$9) + ) + ) + (nop) + (i32.const 1920103026) + ) + ) + ) + ) ) |