Skip to content

Commit 3219c0e

Browse files
committed
[LAA] Directly pass DepChecker to getSource/getDestination (NFC).
Instead of passing LoopAccessInfo only to fetch the MemoryDepChecker, directly pass MemoryDepChecker. This simplifies the code and also allows new uses in places where no LAI is available.
1 parent 57f13b5 commit 3219c0e

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

llvm/include/llvm/Analysis/LoopAccessAnalysis.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ class MemoryDepChecker {
160160
: Source(Source), Destination(Destination), Type(Type) {}
161161

162162
/// Return the source instruction of the dependence.
163-
Instruction *getSource(const LoopAccessInfo &LAI) const;
163+
Instruction *getSource(const MemoryDepChecker &DepChecker) const;
164164
/// Return the destination instruction of the dependence.
165-
Instruction *getDestination(const LoopAccessInfo &LAI) const;
165+
Instruction *getDestination(const MemoryDepChecker &DepChecker) const;
166166

167167
/// Dependence types that don't prevent vectorization.
168168
static VectorizationSafetyStatus isSafeForVectorization(DepType Type);
@@ -833,13 +833,13 @@ class LoopAccessAnalysis
833833
};
834834

835835
inline Instruction *MemoryDepChecker::Dependence::getSource(
836-
const LoopAccessInfo &LAI) const {
837-
return LAI.getDepChecker().getMemoryInstructions()[Source];
836+
const MemoryDepChecker &DepChecker) const {
837+
return DepChecker.getMemoryInstructions()[Source];
838838
}
839839

840840
inline Instruction *MemoryDepChecker::Dependence::getDestination(
841-
const LoopAccessInfo &LAI) const {
842-
return LAI.getDepChecker().getMemoryInstructions()[Destination];
841+
const MemoryDepChecker &DepChecker) const {
842+
return DepChecker.getMemoryInstructions()[Destination];
843843
}
844844

845845
} // End llvm namespace

llvm/include/llvm/Analysis/VectorUtils.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,11 @@ class InterleavedAccessInfo {
795795
void collectDependences() {
796796
if (!areDependencesValid())
797797
return;
798-
auto *Deps = LAI->getDepChecker().getDependences();
798+
const auto &DepChecker = LAI->getDepChecker();
799+
auto *Deps = DepChecker.getDependences();
799800
for (auto Dep : *Deps)
800-
Dependences[Dep.getSource(*LAI)].insert(Dep.getDestination(*LAI));
801+
Dependences[Dep.getSource(DepChecker)].insert(
802+
Dep.getDestination(DepChecker));
801803
}
802804
};
803805

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2726,7 +2726,7 @@ void LoopAccessInfo::emitUnsafeDependenceRemark() {
27262726
"to attempt to isolate the offending operations into a separate "
27272727
"loop";
27282728
OptimizationRemarkAnalysis &R =
2729-
recordAnalysis("UnsafeDep", Dep.getDestination(*this)) << Info;
2729+
recordAnalysis("UnsafeDep", Dep.getDestination(getDepChecker())) << Info;
27302730

27312731
switch (Dep.Type) {
27322732
case MemoryDepChecker::Dependence::NoDep:
@@ -2752,7 +2752,7 @@ void LoopAccessInfo::emitUnsafeDependenceRemark() {
27522752
break;
27532753
}
27542754

2755-
if (Instruction *I = Dep.getSource(*this)) {
2755+
if (Instruction *I = Dep.getSource(getDepChecker())) {
27562756
DebugLoc SourceLoc = I->getDebugLoc();
27572757
if (auto *DD = dyn_cast_or_null<Instruction>(getPointerOperand(I)))
27582758
SourceLoc = DD->getDebugLoc();

llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ class LoadEliminationForLoop {
183183
findStoreToLoadDependences(const LoopAccessInfo &LAI) {
184184
std::forward_list<StoreToLoadForwardingCandidate> Candidates;
185185

186-
const auto *Deps = LAI.getDepChecker().getDependences();
186+
const auto &DepChecker = LAI.getDepChecker();
187+
const auto *Deps = DepChecker.getDependences();
187188
if (!Deps)
188189
return Candidates;
189190

@@ -194,8 +195,8 @@ class LoadEliminationForLoop {
194195
SmallPtrSet<Instruction *, 4> LoadsWithUnknownDepedence;
195196

196197
for (const auto &Dep : *Deps) {
197-
Instruction *Source = Dep.getSource(LAI);
198-
Instruction *Destination = Dep.getDestination(LAI);
198+
Instruction *Source = Dep.getSource(DepChecker);
199+
Instruction *Destination = Dep.getDestination(DepChecker);
199200

200201
if (Dep.Type == MemoryDepChecker::Dependence::Unknown ||
201202
Dep.Type == MemoryDepChecker::Dependence::IndirectUnsafe) {

0 commit comments

Comments
 (0)