[llvm] d7c84d7 - [LAA] Collect loop guards only once in MemoryDepChecker (NFCI).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 21 00:30:58 PDT 2024
Author: Florian Hahn
Date: 2024-08-21T08:28:52+01:00
New Revision: d7c84d7b71fc5ea89b87480ff5d727496288799c
URL: https://github.com/llvm/llvm-project/commit/d7c84d7b71fc5ea89b87480ff5d727496288799c
DIFF: https://github.com/llvm/llvm-project/commit/d7c84d7b71fc5ea89b87480ff5d727496288799c.diff
LOG: [LAA] Collect loop guards only once in MemoryDepChecker (NFCI).
This on its own gives small compile-time improvements in some configs
and enables using loop guards at more places in the future while keeping
compile-time impact low.
https://llvm-compile-time-tracker.com/compare.php?from=c44202574ff9a8c0632aba30c2765b134557435f&to=55ffc3dd920fa9af439fd39f8f9cc13509531420&stat=instructions:u
Added:
Modified:
llvm/include/llvm/Analysis/LoopAccessAnalysis.h
llvm/lib/Analysis/LoopAccessAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
index 87c70abba30fcd..73d9c26ed6b1b7 100644
--- a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
@@ -334,6 +334,9 @@ class MemoryDepChecker {
std::pair<const SCEV *, const SCEV *>>
PointerBounds;
+ /// Cache for the loop guards of InnermostLoop.
+ std::optional<ScalarEvolution::LoopGuards> LoopGuards;
+
/// Check whether there is a plausible dependence between the two
/// accesses.
///
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 872bc52b82cca7..980f142f113265 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -2054,8 +2054,12 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
LLVM_DEBUG(dbgs() << "LAA: Strided accesses are independent\n");
return Dependence::NoDep;
}
- } else
- Dist = SE.applyLoopGuards(Dist, InnermostLoop);
+ } else {
+ if (!LoopGuards)
+ LoopGuards.emplace(
+ ScalarEvolution::LoopGuards::collect(InnermostLoop, SE));
+ Dist = SE.applyLoopGuards(Dist, *LoopGuards);
+ }
// Negative distances are not plausible dependencies.
if (SE.isKnownNonPositive(Dist)) {
More information about the llvm-commits
mailing list