aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
diff options
context:
space:
mode:
authorMax Kazantsev <mkazantsev@azul.com>2022-09-19 17:52:55 +0700
committerMax Kazantsev <mkazantsev@azul.com>2022-09-19 18:01:02 +0700
commit92e9bddc49b6c7bf6c5d59d7dad4ec8255d01c20 (patch)
tree3bab62e50f10aeb5f3eeec9c8fb6c6bababa9fe8 /llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
parentd953d0173776e7f7109b35ac2e74259dd126ab74 (diff)
downloadllvm-92e9bddc49b6c7bf6c5d59d7dad4ec8255d01c20.zip
llvm-92e9bddc49b6c7bf6c5d59d7dad4ec8255d01c20.tar.gz
llvm-92e9bddc49b6c7bf6c5d59d7dad4ec8255d01c20.tar.bz2
[LoopRotate] Drop loop dispositions when rotating loops. PR56260
This is required because if there is a pure loop-invariant instruction, Loop Rotation may decide to not clone it and just hoist it instead. If SCEV has previously cached that it was loop-variant (not being smart enough to prove invariance), we may end up with inconsistent cache state (which may later trigger false-negative assertion failures checking that something was invariant). This is a conservative fix that unconditionally drops the dispositions. We could only drop it if the hoisting has actually happened, but it should take some time understanding whether it's safe with all other things this function does. Differential Revision: https://reviews.llvm.org/D134167 Reviewed By: fhahn
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopRotationUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopRotationUtils.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
index 7bb7cea..da817fb 100644
--- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
@@ -345,8 +345,12 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
// all outer loops because insertion and deletion of blocks that happens
// during the rotation may violate invariants related to backedge taken
// infos in them.
- if (SE)
+ if (SE) {
SE->forgetTopmostLoop(L);
+ // We may hoist some instructions out of loop. In case if they were cached
+ // as "loop variant" or "loop computable", these caches must be dropped.
+ SE->forgetLoopDispositions();
+ }
LLVM_DEBUG(dbgs() << "LoopRotation: rotating "; L->dump());
if (MSSAU && VerifyMemorySSA)