aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/LoopAccessAnalysis.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2024-07-06 22:14:01 +0100
committerFlorian Hahn <flo@fhahn.com>2024-07-06 22:14:01 +0100
commit5028dea65266ab8b7f8f9ebd5d5e01faacebc645 (patch)
tree5b5a18ae6c1e8a5492debc2ba8cd4ad702b3a2b1 /llvm/lib/Analysis/LoopAccessAnalysis.cpp
parent8426b51e0e942b27af8a50b9cee53c1b68d139c2 (diff)
downloadllvm-5028dea65266ab8b7f8f9ebd5d5e01faacebc645.zip
llvm-5028dea65266ab8b7f8f9ebd5d5e01faacebc645.tar.gz
llvm-5028dea65266ab8b7f8f9ebd5d5e01faacebc645.tar.bz2
[LAA] Only invalidate loops that require runtime checks (NFCI).
LAA doesn't keep references to IR outside the loop or references to SCEVs that may be invalidated, unless runtime checks are needed (either memory or SCEV predicates). For the current LAA users, it should be sufficient to invalidate entries for loops that require runtime checks, thus avoiding analyzing loops again unnecessarily. This helps reduce compile-time, in particular when removing the restrictions added in 234cc40adc6. https://llvm-compile-time-tracker.com/compare.php?from=73894dba2cdbcc00678d0c13a6b61765675f60b4&to=05c6bdc41b5f63696ebeb7116325725fa94f66d6&stat=instructions:u
Diffstat (limited to 'llvm/lib/Analysis/LoopAccessAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/LoopAccessAnalysis.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index f132e45..018861a 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -3084,6 +3084,22 @@ const LoopAccessInfo &LoopAccessInfoManager::getInfo(Loop &L) {
return *It->second;
}
+void LoopAccessInfoManager::clear() {
+ SmallVector<Loop *> ToRemove;
+ // Collect LoopAccessInfo entries that may keep references to IR outside the
+ // analyzed loop or SCEVs that may have been modified or invalidated. At the
+ // moment, that is loops requiring memory or SCEV runtime checks, as those cache
+ // SCEVs, e.g. for pointer expressions.
+ for (const auto &[L, LAI] : LoopAccessInfoMap) {
+ if (LAI->getRuntimePointerChecking()->getChecks().empty() &&
+ LAI->getPSE().getPredicate().isAlwaysTrue())
+ continue;
+ ToRemove.push_back(L);
+ }
+
+ for (Loop *L : ToRemove)
+ LoopAccessInfoMap.erase(L);
+}
bool LoopAccessInfoManager::invalidate(
Function &F, const PreservedAnalyses &PA,