summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/passes/Vacuum.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp
index 1b4da4c47..63a098fc0 100644
--- a/src/passes/Vacuum.cpp
+++ b/src/passes/Vacuum.cpp
@@ -213,11 +213,15 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum>> {
curr->ifFalse = nullptr;
curr->condition = Builder(*getModule()).makeUnary(EqZInt32, curr->condition);
} else if (curr->ifTrue->is<Drop>() && curr->ifFalse->is<Drop>()) {
- // instead of dropping both sides, drop the if
- curr->ifTrue = curr->ifTrue->cast<Drop>()->value;
- curr->ifFalse = curr->ifFalse->cast<Drop>()->value;
- curr->finalize();
- replaceCurrent(Builder(*getModule()).makeDrop(curr));
+ // instead of dropping both sides, drop the if, if they are the same type
+ auto* left = curr->ifTrue->cast<Drop>()->value;
+ auto* right = curr->ifFalse->cast<Drop>()->value;
+ if (left->type == right->type) {
+ curr->ifTrue = left;
+ curr->ifFalse = right;
+ curr->finalize();
+ replaceCurrent(Builder(*getModule()).makeDrop(curr));
+ }
}
} else {
// no else