diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-11-26 17:32:31 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-26 17:32:31 -0800 |
commit | 9f49e3d9c92703c3f5cf3589a78a3318bfe2bca4 (patch) | |
tree | 158fe730778a8d3bc526a186220d96aeb813809f /src | |
parent | 4d65912ee77fd665a1bfff50d81e0aa896dab8a5 (diff) | |
download | binaryen-9f49e3d9c92703c3f5cf3589a78a3318bfe2bca4.tar.gz binaryen-9f49e3d9c92703c3f5cf3589a78a3318bfe2bca4.tar.bz2 binaryen-9f49e3d9c92703c3f5cf3589a78a3318bfe2bca4.zip |
Branches only invalidate side effects (#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.
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/effects.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/ir/effects.h b/src/ir/effects.h index 8c95f463d..394bf0116 100644 --- a/src/ir/effects.h +++ b/src/ir/effects.h @@ -74,9 +74,10 @@ struct EffectAnalyzer : public PostWalker<EffectAnalyzer> { // 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) bool invalidates(EffectAnalyzer& other) { - if (branches || other.branches - || ((writesMemory || calls) && other.accessesMemory()) - || (accessesMemory() && (other.writesMemory || other.calls))) { + if ((branches && other.hasSideEffects()) || + (other.branches && hasSideEffects()) || + ((writesMemory || calls) && other.accessesMemory()) || + (accessesMemory() && (other.writesMemory || other.calls))) { return true; } // All atomics are sequentially consistent for now, and ordered wrt other |