summaryrefslogtreecommitdiff
path: root/src/passes/LoopInvariantCodeMotion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/LoopInvariantCodeMotion.cpp')
-rw-r--r--src/passes/LoopInvariantCodeMotion.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/passes/LoopInvariantCodeMotion.cpp b/src/passes/LoopInvariantCodeMotion.cpp
index 1007e57b3..f339f8126 100644
--- a/src/passes/LoopInvariantCodeMotion.cpp
+++ b/src/passes/LoopInvariantCodeMotion.cpp
@@ -120,9 +120,10 @@ struct LoopInvariantCodeMotion
// The rest of the loop's effects matter too, we must also
// take into account global state like interacting loads and
// stores.
- bool unsafeToMove =
- effects.writesGlobalState() || effectsSoFar.invalidates(effects) ||
- (effects.readsGlobalState() && loopEffects.writesGlobalState());
+ bool unsafeToMove = effects.writesGlobalState() ||
+ effectsSoFar.invalidates(effects) ||
+ (effects.readsMutableGlobalState() &&
+ loopEffects.writesGlobalState());
// TODO: look into optimizing this with exceptions. for now, disallow
if (effects.throws || loopEffects.throws) {
unsafeToMove = true;