diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-09-23 20:34:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-23 20:34:56 -0700 |
commit | b6469ed600832887e8874d1a0407b993dd2c03e8 (patch) | |
tree | 325cafc1625265a8d7569a4f2b2a45910e4040fb /src/passes/Vacuum.cpp | |
parent | dc82f588309f1a4413be18460159699df74661c4 (diff) | |
parent | 7d5180a5b3e369634dbc1442117068d332d71049 (diff) | |
download | binaryen-b6469ed600832887e8874d1a0407b993dd2c03e8.tar.gz binaryen-b6469ed600832887e8874d1a0407b993dd2c03e8.tar.bz2 binaryen-b6469ed600832887e8874d1a0407b993dd2c03e8.zip |
Merge pull request #710 from WebAssembly/autodrop-fix
Autodrop fixes
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 |