summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-10-19 09:07:40 -0700
committerGitHub <noreply@github.com>2021-10-19 09:07:40 -0700
commitc19ff59c71824b34fa312aac9ad979e2198d7d36 (patch)
treec0739ad5f1b93a2e497c38f493135fd483e478dc /src
parentbe02d3f0f2689475f31c4523010eed58f39d27cb (diff)
downloadbinaryen-c19ff59c71824b34fa312aac9ad979e2198d7d36.tar.gz
binaryen-c19ff59c71824b34fa312aac9ad979e2198d7d36.tar.bz2
binaryen-c19ff59c71824b34fa312aac9ad979e2198d7d36.zip
MergeBlocks: optimize If conditions (#4260)
Code in the If condition can be moved out to before the if. Existing test updates are 99% whitespace.
Diffstat (limited to 'src')
-rw-r--r--src/passes/MergeBlocks.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/passes/MergeBlocks.cpp b/src/passes/MergeBlocks.cpp
index b77dbef83..6ba486717 100644
--- a/src/passes/MergeBlocks.cpp
+++ b/src/passes/MergeBlocks.cpp
@@ -520,6 +520,11 @@ struct MergeBlocks
}
}
+ void visitIf(If* curr) {
+ // We can move code out of the condition, but not any of the other children.
+ optimize(curr, curr->condition);
+ }
+
void optimizeTernary(Expression* curr,
Expression*& first,
Expression*& second,