summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-10-13 16:55:02 -0700
committerGitHub <noreply@github.com>2021-10-13 16:55:02 -0700
commitf1823c3a32a6901512cab3b4224ce365d06dd0b7 (patch)
tree73b0ca3a9fd1e84d9ab0dcb431d98d423afb8542 /src
parentbf4b4b2012992a5e8f59359d0dd6c89df1993cca (diff)
downloadbinaryen-f1823c3a32a6901512cab3b4224ce365d06dd0b7.tar.gz
binaryen-f1823c3a32a6901512cab3b4224ce365d06dd0b7.tar.bz2
binaryen-f1823c3a32a6901512cab3b4224ce365d06dd0b7.zip
MergeBlocks: Allow side effects in a ternary's first element (#4238)
Side effects in the first element are always ok there, as they are not moved across anything else: they happen before their parent both before and after the opt. The pass just left ternary as a TODO, so do at least one part of that now (we can do the rest as well, with some care). This is fairly useful on array.set which has 3 operands, and the first often has interesting things in it.
Diffstat (limited to 'src')
-rw-r--r--src/passes/MergeBlocks.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/passes/MergeBlocks.cpp b/src/passes/MergeBlocks.cpp
index 9d797ae0a..b77dbef83 100644
--- a/src/passes/MergeBlocks.cpp
+++ b/src/passes/MergeBlocks.cpp
@@ -524,14 +524,10 @@ struct MergeBlocks
Expression*& first,
Expression*& second,
Expression*& third) {
- // TODO: for now, just stop when we see any side effect. instead, we could
- // check effects carefully for reordering
Block* outer = nullptr;
- if (EffectAnalyzer(getPassOptions(), *getModule(), first)
- .hasSideEffects()) {
- return;
- }
outer = optimize(curr, first, outer);
+ // TODO: for now, just stop when we see any side effect after the first
+ // item, but we could handle them carefully like we do for binaries.
if (EffectAnalyzer(getPassOptions(), *getModule(), second)
.hasSideEffects()) {
return;