diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-09-23 15:35:58 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-09-23 15:46:12 -0700 |
commit | 8ef9aafab1a2c47f9a09c8e64636da570870dc00 (patch) | |
tree | 25940052eb129a642f2121e4b9f0941077a4d9e9 /src/passes/Vacuum.cpp | |
parent | 8f897c7d5543fd1529b8279801ddbb59ffff7f1b (diff) | |
download | binaryen-8ef9aafab1a2c47f9a09c8e64636da570870dc00.tar.gz binaryen-8ef9aafab1a2c47f9a09c8e64636da570870dc00.tar.bz2 binaryen-8ef9aafab1a2c47f9a09c8e64636da570870dc00.zip |
replace two drops in an if-else with one on the if
Diffstat (limited to 'src/passes/Vacuum.cpp')
-rw-r--r-- | src/passes/Vacuum.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index 0fdd12dec..03becb04c 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -193,9 +193,14 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum, Visitor<Vacuum>> curr->ifTrue = curr->ifFalse; 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)); } - } - if (!curr->ifFalse) { + } else { // no else if (curr->ifTrue->is<Nop>()) { // no nothing |