aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/LoopAccessAnalysis.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2024-05-29 14:18:03 -0700
committerFlorian Hahn <flo@fhahn.com>2024-05-29 14:18:05 -0700
commit1880a7bf18f8bf6497eddeda5cea49b507413f3a (patch)
tree4e5e287b24a51797e657b0c2b39473374a43b854 /llvm/lib/Analysis/LoopAccessAnalysis.cpp
parentbfabc958c7c0d7ddc15f23383d9da836e8c6093f (diff)
downloadllvm-1880a7bf18f8bf6497eddeda5cea49b507413f3a.zip
llvm-1880a7bf18f8bf6497eddeda5cea49b507413f3a.tar.gz
llvm-1880a7bf18f8bf6497eddeda5cea49b507413f3a.tar.bz2
[LAA] Move getDependenceDistanceStrideAndSize to MemoryDepChecker (NFC).
This avoids unnecessarily passing a number of parameters, and avoids needing to add extra parameters in the future.
Diffstat (limited to 'llvm/lib/Analysis/LoopAccessAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/LoopAccessAnalysis.cpp43
1 files changed, 10 insertions, 33 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index ab77e35..13005cb 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1903,37 +1903,13 @@ isLoopVariantIndirectAddress(ArrayRef<const Value *> UnderlyingObjects,
});
}
-namespace {
-struct DepDistanceStrideAndSizeInfo {
- const SCEV *Dist;
- uint64_t StrideA;
- uint64_t StrideB;
- uint64_t TypeByteSize;
- bool AIsWrite;
- bool BIsWrite;
-
- DepDistanceStrideAndSizeInfo(const SCEV *Dist, uint64_t StrideA,
- uint64_t StrideB, uint64_t TypeByteSize,
- bool AIsWrite, bool BIsWrite)
- : Dist(Dist), StrideA(StrideA), StrideB(StrideB),
- TypeByteSize(TypeByteSize), AIsWrite(AIsWrite), BIsWrite(BIsWrite) {}
-};
-} // namespace
-
-// Get the dependence distance, strides, type size and whether it is a write for
-// the dependence between A and B. Returns a DepType, if we can prove there's
-// no dependence or the analysis fails. Outlined to lambda to limit he scope
-// of various temporary variables, like A/BPtr, StrideA/BPtr and others.
-// Returns either the dependence result, if it could already be determined, or a
-// struct containing (Distance, Stride, TypeSize, AIsWrite, BIsWrite).
-static std::variant<MemoryDepChecker::Dependence::DepType,
- DepDistanceStrideAndSizeInfo>
-getDependenceDistanceStrideAndSize(
+std::variant<MemoryDepChecker::Dependence::DepType,
+ MemoryDepChecker::DepDistanceStrideAndSizeInfo>
+MemoryDepChecker::getDependenceDistanceStrideAndSize(
const AccessAnalysis::MemAccessInfo &A, Instruction *AInst,
const AccessAnalysis::MemAccessInfo &B, Instruction *BInst,
- const DenseMap<Value *, const SCEV *> &Strides,
- const DenseMap<Value *, SmallVector<const Value *, 16>> &UnderlyingObjects,
- PredicatedScalarEvolution &PSE, const Loop *InnermostLoop) {
+ const DenseMap<Value *, SmallVector<const Value *, 16>>
+ &UnderlyingObjects) {
auto &DL = InnermostLoop->getHeader()->getModule()->getDataLayout();
auto &SE = *PSE.getSE();
auto [APtr, AIsWrite] = A;
@@ -1952,9 +1928,11 @@ getDependenceDistanceStrideAndSize(
return MemoryDepChecker::Dependence::Unknown;
int64_t StrideAPtr =
- getPtrStride(PSE, ATy, APtr, InnermostLoop, Strides, true).value_or(0);
+ getPtrStride(PSE, ATy, APtr, InnermostLoop, SymbolicStrides, true)
+ .value_or(0);
int64_t StrideBPtr =
- getPtrStride(PSE, BTy, BPtr, InnermostLoop, Strides, true).value_or(0);
+ getPtrStride(PSE, BTy, BPtr, InnermostLoop, SymbolicStrides, true)
+ .value_or(0);
const SCEV *Src = PSE.getSCEV(APtr);
const SCEV *Sink = PSE.getSCEV(BPtr);
@@ -2033,8 +2011,7 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
// Get the dependence distance, stride, type size and what access writes for
// the dependence between A and B.
auto Res = getDependenceDistanceStrideAndSize(
- A, InstMap[AIdx], B, InstMap[BIdx], SymbolicStrides, UnderlyingObjects,
- PSE, InnermostLoop);
+ A, InstMap[AIdx], B, InstMap[BIdx], UnderlyingObjects);
if (std::holds_alternative<Dependence::DepType>(Res))
return std::get<Dependence::DepType>(Res);