[llvm] b74f50a - [LAA] Store reference to SymbolicStrides in MemoryDepChecker (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed May 29 13:37:34 PDT 2024
Author: Florian Hahn
Date: 2024-05-29T13:37:13-07:00
New Revision: b74f50a26980233c6bdf3bcacea1473a4a5e0d42
URL: https://github.com/llvm/llvm-project/commit/b74f50a26980233c6bdf3bcacea1473a4a5e0d42
DIFF: https://github.com/llvm/llvm-project/commit/b74f50a26980233c6bdf3bcacea1473a4a5e0d42.diff
LOG: [LAA] Store reference to SymbolicStrides in MemoryDepChecker (NFC).
This reduces the need for explicitly passing it through multiple layers
of function calls.
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 c22e1d470f380..acb3e1406032f 100644
--- a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
@@ -182,8 +182,9 @@ class MemoryDepChecker {
};
MemoryDepChecker(PredicatedScalarEvolution &PSE, const Loop *L,
+ const DenseMap<Value *, const SCEV *> &SymbolicStrides,
unsigned MaxTargetVectorWidthInBits)
- : PSE(PSE), InnermostLoop(L),
+ : PSE(PSE), InnermostLoop(L), SymbolicStrides(SymbolicStrides),
MaxTargetVectorWidthInBits(MaxTargetVectorWidthInBits) {}
/// Register the location (instructions are given increasing numbers)
@@ -198,7 +199,6 @@ class MemoryDepChecker {
///
/// Only checks sets with elements in \p CheckDeps.
bool areDepsSafe(DepCandidates &AccessSets, MemAccessInfoList &CheckDeps,
- const DenseMap<Value *, const SCEV *> &Strides,
const DenseMap<Value *, SmallVector<const Value *, 16>>
&UnderlyingObjects);
@@ -278,6 +278,10 @@ class MemoryDepChecker {
PredicatedScalarEvolution &PSE;
const Loop *InnermostLoop;
+ /// Reference to map of pointer values to
+ /// their stride symbols, if they have a symbolic stride.
+ const DenseMap<Value *, const SCEV *> &SymbolicStrides;
+
/// Maps access locations (ptr, read/write) to program order.
DenseMap<MemAccessInfo, std::vector<unsigned> > Accesses;
@@ -336,7 +340,7 @@ class MemoryDepChecker {
/// Otherwise, this function returns true signaling a possible dependence.
Dependence::DepType
isDependent(const MemAccessInfo &A, unsigned AIdx, const MemAccessInfo &B,
- unsigned BIdx, const DenseMap<Value *, const SCEV *> &Strides,
+ unsigned BIdx,
const DenseMap<Value *, SmallVector<const Value *, 16>>
&UnderlyingObjects);
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index bd4c2a35ebf2c..ab77e35cf6bd5 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -2025,7 +2025,7 @@ getDependenceDistanceStrideAndSize(
MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
const MemAccessInfo &A, unsigned AIdx, const MemAccessInfo &B,
- unsigned BIdx, const DenseMap<Value *, const SCEV *> &Strides,
+ unsigned BIdx,
const DenseMap<Value *, SmallVector<const Value *, 16>>
&UnderlyingObjects) {
assert(AIdx < BIdx && "Must pass arguments in program order");
@@ -2033,8 +2033,8 @@ 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], Strides, UnderlyingObjects, PSE,
- InnermostLoop);
+ A, InstMap[AIdx], B, InstMap[BIdx], SymbolicStrides, UnderlyingObjects,
+ PSE, InnermostLoop);
if (std::holds_alternative<Dependence::DepType>(Res))
return std::get<Dependence::DepType>(Res);
@@ -2269,7 +2269,6 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
bool MemoryDepChecker::areDepsSafe(
DepCandidates &AccessSets, MemAccessInfoList &CheckDeps,
- const DenseMap<Value *, const SCEV *> &Strides,
const DenseMap<Value *, SmallVector<const Value *, 16>>
&UnderlyingObjects) {
@@ -2314,9 +2313,8 @@ bool MemoryDepChecker::areDepsSafe(
if (*I1 > *I2)
std::swap(A, B);
- Dependence::DepType Type =
- isDependent(*A.first, A.second, *B.first, B.second, Strides,
- UnderlyingObjects);
+ Dependence::DepType Type = isDependent(*A.first, A.second, *B.first,
+ B.second, UnderlyingObjects);
mergeInStatus(Dependence::isSafeForVectorization(Type));
// Gather dependences unless we accumulated MaxDependences
@@ -2674,9 +2672,9 @@ void LoopAccessInfo::analyzeLoop(AAResults *AA, LoopInfo *LI,
CanVecMem = true;
if (Accesses.isDependencyCheckNeeded()) {
LLVM_DEBUG(dbgs() << "LAA: Checking memory dependencies\n");
- CanVecMem = DepChecker->areDepsSafe(
- DependentAccesses, Accesses.getDependenciesToCheck(), SymbolicStrides,
- Accesses.getUnderlyingObjects());
+ CanVecMem = DepChecker->areDepsSafe(DependentAccesses,
+ Accesses.getDependenciesToCheck(),
+ Accesses.getUnderlyingObjects());
if (!CanVecMem && DepChecker->shouldRetryWithRuntimeCheck()) {
LLVM_DEBUG(dbgs() << "LAA: Retrying with memory checks\n");
@@ -3066,8 +3064,8 @@ LoopAccessInfo::LoopAccessInfo(Loop *L, ScalarEvolution *SE,
if (ScalableWidth.isNonZero())
MaxTargetVectorWidthInBits = std::numeric_limits<unsigned>::max();
}
- DepChecker =
- std::make_unique<MemoryDepChecker>(*PSE, L, MaxTargetVectorWidthInBits);
+ DepChecker = std::make_unique<MemoryDepChecker>(*PSE, L, SymbolicStrides,
+ MaxTargetVectorWidthInBits);
PtrRtChecking = std::make_unique<RuntimePointerChecking>(*DepChecker, SE);
if (canAnalyzeLoop())
analyzeLoop(AA, LI, TLI, DT);
More information about the llvm-commits
mailing list