diff options
-rw-r--r-- | src/passes/Vacuum.cpp | 6 | ||||
-rw-r--r-- | test/passes/vacuum.txt | 18 | ||||
-rw-r--r-- | test/passes/vacuum.wast | 18 |
3 files changed, 38 insertions, 4 deletions
diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index 63a098fc0..13b9c62fd 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -288,14 +288,12 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum>> { auto* iff = curr->value->dynCast<If>(); if (iff && iff->ifFalse && isConcreteWasmType(iff->type)) { // reuse the drop in both cases - if (iff->ifTrue->type == unreachable) { - assert(isConcreteWasmType(iff->ifFalse->type)); + if (iff->ifTrue->type == unreachable && isConcreteWasmType(iff->ifFalse->type)) { curr->value = iff->ifFalse; iff->ifFalse = curr; iff->type = none; replaceCurrent(iff); - } else if (iff->ifFalse->type == unreachable) { - assert(isConcreteWasmType(iff->ifTrue->type)); + } else if (iff->ifFalse->type == unreachable && isConcreteWasmType(iff->ifTrue->type)) { curr->value = iff->ifTrue; iff->ifTrue = curr; iff->type = none; diff --git a/test/passes/vacuum.txt b/test/passes/vacuum.txt index dda7d8abf..f64ef0868 100644 --- a/test/passes/vacuum.txt +++ b/test/passes/vacuum.txt @@ -241,4 +241,22 @@ (i32.const 7) ) ) + (func $drop-if-both-unreachable (type $1) (param $0 i32) + (block $out + (drop + (if i32 + (get_local $0) + (br $out) + (br $out) + ) + ) + ) + (drop + (if i32 + (get_local $0) + (unreachable) + (unreachable) + ) + ) + ) ) diff --git a/test/passes/vacuum.wast b/test/passes/vacuum.wast index 06dea2034..8b97b9386 100644 --- a/test/passes/vacuum.wast +++ b/test/passes/vacuum.wast @@ -445,4 +445,22 @@ (if (i32.const 0) (call $if-const (i32.const 4)) (call $if-const (i32.const 5))) (if (i32.const 6) (call $if-const (i32.const 7)) (call $if-const (i32.const 8))) ) + (func $drop-if-both-unreachable (param $0 i32) + (block $out + (drop + (if i32 + (get_local $0) + (br $out) + (br $out) + ) + ) + ) + (drop + (if i32 + (get_local $0) + (unreachable) + (unreachable) + ) + ) + ) ) |