Skip to content

Commit 1880a7b

Browse files
committed
[LAA] Move getDependenceDistanceStrideAndSize to MemoryDepChecker (NFC).
This avoids unnecessarily passing a number of parameters, and avoids needing to add extra parameters in the future.
1 parent bfabc95 commit 1880a7b

File tree

2 files changed

+39
-33
lines changed

2 files changed

+39
-33
lines changed

llvm/include/llvm/Analysis/LoopAccessAnalysis.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,35 @@ class MemoryDepChecker {
355355
/// either PossiblySafeWithRtChecks or Unsafe and from
356356
/// PossiblySafeWithRtChecks to Unsafe.
357357
void mergeInStatus(VectorizationSafetyStatus S);
358+
359+
struct DepDistanceStrideAndSizeInfo {
360+
const SCEV *Dist;
361+
uint64_t StrideA;
362+
uint64_t StrideB;
363+
uint64_t TypeByteSize;
364+
bool AIsWrite;
365+
bool BIsWrite;
366+
367+
DepDistanceStrideAndSizeInfo(const SCEV *Dist, uint64_t StrideA,
368+
uint64_t StrideB, uint64_t TypeByteSize,
369+
bool AIsWrite, bool BIsWrite)
370+
: Dist(Dist), StrideA(StrideA), StrideB(StrideB),
371+
TypeByteSize(TypeByteSize), AIsWrite(AIsWrite), BIsWrite(BIsWrite) {}
372+
};
373+
374+
/// Get the dependence distance, strides, type size and whether it is a write
375+
/// for the dependence between A and B. Returns a DepType, if we can prove
376+
/// there's no dependence or the analysis fails. Outlined to lambda to limit
377+
/// he scope of various temporary variables, like A/BPtr, StrideA/BPtr and
378+
/// others. Returns either the dependence result, if it could already be
379+
/// determined, or a struct containing (Distance, Stride, TypeSize, AIsWrite,
380+
/// BIsWrite).
381+
std::variant<Dependence::DepType, DepDistanceStrideAndSizeInfo>
382+
getDependenceDistanceStrideAndSize(
383+
const MemAccessInfo &A, Instruction *AInst, const MemAccessInfo &B,
384+
Instruction *BInst,
385+
const DenseMap<Value *, SmallVector<const Value *, 16>>
386+
&UnderlyingObjects);
358387
};
359388

360389
class RuntimePointerChecking;

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,37 +1903,13 @@ isLoopVariantIndirectAddress(ArrayRef<const Value *> UnderlyingObjects,
19031903
});
19041904
}
19051905

1906-
namespace {
1907-
struct DepDistanceStrideAndSizeInfo {
1908-
const SCEV *Dist;
1909-
uint64_t StrideA;
1910-
uint64_t StrideB;
1911-
uint64_t TypeByteSize;
1912-
bool AIsWrite;
1913-
bool BIsWrite;
1914-
1915-
DepDistanceStrideAndSizeInfo(const SCEV *Dist, uint64_t StrideA,
1916-
uint64_t StrideB, uint64_t TypeByteSize,
1917-
bool AIsWrite, bool BIsWrite)
1918-
: Dist(Dist), StrideA(StrideA), StrideB(StrideB),
1919-
TypeByteSize(TypeByteSize), AIsWrite(AIsWrite), BIsWrite(BIsWrite) {}
1920-
};
1921-
} // namespace
1922-
1923-
// Get the dependence distance, strides, type size and whether it is a write for
1924-
// the dependence between A and B. Returns a DepType, if we can prove there's
1925-
// no dependence or the analysis fails. Outlined to lambda to limit he scope
1926-
// of various temporary variables, like A/BPtr, StrideA/BPtr and others.
1927-
// Returns either the dependence result, if it could already be determined, or a
1928-
// struct containing (Distance, Stride, TypeSize, AIsWrite, BIsWrite).
1929-
static std::variant<MemoryDepChecker::Dependence::DepType,
1930-
DepDistanceStrideAndSizeInfo>
1931-
getDependenceDistanceStrideAndSize(
1906+
std::variant<MemoryDepChecker::Dependence::DepType,
1907+
MemoryDepChecker::DepDistanceStrideAndSizeInfo>
1908+
MemoryDepChecker::getDependenceDistanceStrideAndSize(
19321909
const AccessAnalysis::MemAccessInfo &A, Instruction *AInst,
19331910
const AccessAnalysis::MemAccessInfo &B, Instruction *BInst,
1934-
const DenseMap<Value *, const SCEV *> &Strides,
1935-
const DenseMap<Value *, SmallVector<const Value *, 16>> &UnderlyingObjects,
1936-
PredicatedScalarEvolution &PSE, const Loop *InnermostLoop) {
1911+
const DenseMap<Value *, SmallVector<const Value *, 16>>
1912+
&UnderlyingObjects) {
19371913
auto &DL = InnermostLoop->getHeader()->getModule()->getDataLayout();
19381914
auto &SE = *PSE.getSE();
19391915
auto [APtr, AIsWrite] = A;
@@ -1952,9 +1928,11 @@ getDependenceDistanceStrideAndSize(
19521928
return MemoryDepChecker::Dependence::Unknown;
19531929

19541930
int64_t StrideAPtr =
1955-
getPtrStride(PSE, ATy, APtr, InnermostLoop, Strides, true).value_or(0);
1931+
getPtrStride(PSE, ATy, APtr, InnermostLoop, SymbolicStrides, true)
1932+
.value_or(0);
19561933
int64_t StrideBPtr =
1957-
getPtrStride(PSE, BTy, BPtr, InnermostLoop, Strides, true).value_or(0);
1934+
getPtrStride(PSE, BTy, BPtr, InnermostLoop, SymbolicStrides, true)
1935+
.value_or(0);
19581936

19591937
const SCEV *Src = PSE.getSCEV(APtr);
19601938
const SCEV *Sink = PSE.getSCEV(BPtr);
@@ -2033,8 +2011,7 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
20332011
// Get the dependence distance, stride, type size and what access writes for
20342012
// the dependence between A and B.
20352013
auto Res = getDependenceDistanceStrideAndSize(
2036-
A, InstMap[AIdx], B, InstMap[BIdx], SymbolicStrides, UnderlyingObjects,
2037-
PSE, InnermostLoop);
2014+
A, InstMap[AIdx], B, InstMap[BIdx], UnderlyingObjects);
20382015
if (std::holds_alternative<Dependence::DepType>(Res))
20392016
return std::get<Dependence::DepType>(Res);
20402017

0 commit comments

Comments
 (0)