Skip to content

Commit 9f49e3d

Browse files
authored
Branches only invalidate side effects (WebAssembly#1765)
Previously we assumed that we can't reorder a branching instruction and anything else. However, the only risk is when the other thing has side effects.
1 parent 4d65912 commit 9f49e3d

5 files changed

Lines changed: 7145 additions & 7147 deletions

File tree

src/ir/effects.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ struct EffectAnalyzer : public PostWalker<EffectAnalyzer> {
7474

7575
// checks if these effects would invalidate another set (e.g., if we write, we invalidate someone that reads, they can't be moved past us)
7676
bool invalidates(EffectAnalyzer& other) {
77-
if (branches || other.branches
78-
|| ((writesMemory || calls) && other.accessesMemory())
79-
|| (accessesMemory() && (other.writesMemory || other.calls))) {
77+
if ((branches && other.hasSideEffects()) ||
78+
(other.branches && hasSideEffects()) ||
79+
((writesMemory || calls) && other.accessesMemory()) ||
80+
(accessesMemory() && (other.writesMemory || other.calls))) {
8081
return true;
8182
}
8283
// All atomics are sequentially consistent for now, and ordered wrt other

0 commit comments

Comments
 (0)