summaryrefslogtreecommitdiff
path: root/src/passes/CodePushing.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/CodePushing.cpp')
-rw-r--r--src/passes/CodePushing.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/passes/CodePushing.cpp b/src/passes/CodePushing.cpp
index 397a20bab..f4beff1a8 100644
--- a/src/passes/CodePushing.cpp
+++ b/src/passes/CodePushing.cpp
@@ -115,7 +115,14 @@ private:
auto* set = curr->dynCast<SetLocal>();
if (!set) return nullptr;
auto index = set->index;
- return analyzer.isSFA(index) && numGetsSoFar[index] == analyzer.getNumGets(index) ? set : nullptr;
+ // to be pushable, this must be SFA and the right # of gets,
+ // but also have no side effects, as it may not execute if pushed.
+ if (analyzer.isSFA(index) &&
+ numGetsSoFar[index] == analyzer.getNumGets(index) &&
+ !EffectAnalyzer(set->value).hasSideEffects()) {
+ return set;
+ }
+ return nullptr;
}
// Push past conditional control flow.