diff options
author | Nikita Popov <npopov@redhat.com> | 2023-05-04 15:29:30 +0200 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2023-05-05 10:03:42 +0200 |
commit | 00ff746f6e81b6be5886160327805020c39e4ce3 (patch) | |
tree | 89ea6d477122e7ed50e273e7d953c2941785d4af /llvm/lib/Transforms/Utils/LoopSimplify.cpp | |
parent | 29712ccda62012e615b8c55bc6a3fa7454c10c42 (diff) | |
download | llvm-00ff746f6e81b6be5886160327805020c39e4ce3.zip llvm-00ff746f6e81b6be5886160327805020c39e4ce3.tar.gz llvm-00ff746f6e81b6be5886160327805020c39e4ce3.tar.bz2 |
[LoopSimplify] Reduce amount of redundant SCEV invalidation (NFCI)
We are simplifying the loop and all its children. Each time, we
invalidate the top-most loop. The top-most loop is going to be
the same every time. The cost of SCEV invalidation is largely
independent from how data about the loop is actually cached, so
we should avoid redundant invalidations.
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopSimplify.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopSimplify.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp index 692a872..1b36a29b 100644 --- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp +++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp @@ -693,12 +693,6 @@ ReprocessLoop: } } - // Changing exit conditions for blocks may affect exit counts of this loop and - // any of its paretns, so we must invalidate the entire subtree if we've made - // any changes. - if (Changed && SE) - SE->forgetTopmostLoop(L); - if (MSSAU && VerifyMemorySSA) MSSAU->getMemorySSA()->verifyMemorySSA(); @@ -737,6 +731,13 @@ bool llvm::simplifyLoop(Loop *L, DominatorTree *DT, LoopInfo *LI, Changed |= simplifyOneLoop(Worklist.pop_back_val(), Worklist, DT, LI, SE, AC, MSSAU, PreserveLCSSA); + // Changing exit conditions for blocks may affect exit counts of this loop and + // any of its parents, so we must invalidate the entire subtree if we've made + // any changes. Do this here rather than in simplifyOneLoop() as the top-most + // loop is going to be the same for all child loops. + if (Changed && SE) + SE->forgetTopmostLoop(L); + return Changed; } |