Skip to content

Commit 2233dcf

Browse files
committed
Obtain AA via LoopVectorize
1 parent e80821e commit 2233dcf

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

llvm/include/llvm/Analysis/LoopAccessAnalysis.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,6 @@ class LoopAccessInfoManager {
973973

974974
LLVM_ABI void clear();
975975

976-
LLVM_ABI AAResults *getAAResults() { return &AA; }
977-
978976
LLVM_ABI bool invalidate(Function &F, const PreservedAnalyses &PA,
979977
FunctionAnalysisManager::Invalidator &Inv);
980978
};

llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,18 @@ struct HistogramInfo {
251251
/// induction variable and the different reduction variables.
252252
class LoopVectorizationLegality {
253253
public:
254-
LoopVectorizationLegality(
255-
Loop *L, PredicatedScalarEvolution &PSE, DominatorTree *DT,
256-
TargetTransformInfo *TTI, TargetLibraryInfo *TLI, Function *F,
257-
LoopAccessInfoManager &LAIs, LoopInfo *LI, OptimizationRemarkEmitter *ORE,
258-
LoopVectorizationRequirements *R, LoopVectorizeHints *H, DemandedBits *DB,
259-
AssumptionCache *AC, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI)
254+
LoopVectorizationLegality(Loop *L, PredicatedScalarEvolution &PSE,
255+
DominatorTree *DT, TargetTransformInfo *TTI,
256+
TargetLibraryInfo *TLI, Function *F,
257+
LoopAccessInfoManager &LAIs, LoopInfo *LI,
258+
OptimizationRemarkEmitter *ORE,
259+
LoopVectorizationRequirements *R,
260+
LoopVectorizeHints *H, DemandedBits *DB,
261+
AssumptionCache *AC, BlockFrequencyInfo *BFI,
262+
ProfileSummaryInfo *PSI, AAResults *AA)
260263
: TheLoop(L), LI(LI), PSE(PSE), TTI(TTI), TLI(TLI), DT(DT), LAIs(LAIs),
261-
ORE(ORE), Requirements(R), Hints(H), DB(DB), AC(AC), BFI(BFI),
262-
PSI(PSI) {}
264+
ORE(ORE), Requirements(R), Hints(H), DB(DB), AC(AC), BFI(BFI), PSI(PSI),
265+
AA(AA) {}
263266

264267
/// ReductionList contains the reduction descriptors for all
265268
/// of the reductions that were found in the loop.
@@ -721,6 +724,10 @@ class LoopVectorizationLegality {
721724
BlockFrequencyInfo *BFI;
722725
ProfileSummaryInfo *PSI;
723726

727+
// Alias Analysis results used to check for possible aliasing with loads
728+
// used in uncountable exit conditions.
729+
AAResults *AA;
730+
724731
/// If we discover function calls within the loop which have a valid
725732
/// vectorized variant, record that fact so that LoopVectorize can
726733
/// (potentially) make a better decision on the maximum VF and enable

llvm/include/llvm/Transforms/Vectorize/LoopVectorize.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ struct LoopVectorizePass : public PassInfoMixin<LoopVectorizePass> {
152152
LoopAccessInfoManager *LAIs;
153153
OptimizationRemarkEmitter *ORE;
154154
ProfileSummaryInfo *PSI;
155+
AAResults *AA;
155156

156157
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
157158
LLVM_ABI void

llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,8 +1830,6 @@ bool LoopVectorizationLegality::isVectorizableEarlyExitLoop() {
18301830
<< "\n");
18311831
}
18321832

1833-
1834-
18351833
[[maybe_unused]] const SCEV *SymbolicMaxBTC =
18361834
PSE.getSymbolicMaxBackedgeTakenCount();
18371835
// Since we have an exact exit count for the latch and the early exit
@@ -1927,7 +1925,6 @@ bool LoopVectorizationLegality::canUncountableExitConditionLoadBeMoved(
19271925
// Prohibit any potential aliasing with any instruction in the loop which
19281926
// might store to memory.
19291927
// FIXME: Relax this constraint where possible.
1930-
AAResults *AA = LAIs.getAAResults();
19311928
Value *Ptr = CriticalUncountableExitConditionLoad->getPointerOperand();
19321929
for (auto *BB : TheLoop->blocks()) {
19331930
for (auto &I : *BB) {

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9811,7 +9811,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
98119811
// Check if it is legal to vectorize the loop.
98129812
LoopVectorizationRequirements Requirements;
98139813
LoopVectorizationLegality LVL(L, PSE, DT, TTI, TLI, F, *LAIs, LI, ORE,
9814-
&Requirements, &Hints, DB, AC, BFI, PSI);
9814+
&Requirements, &Hints, DB, AC, BFI, PSI, AA);
98159815
if (!LVL.canVectorize(EnableVPlanNativePath)) {
98169816
LLVM_DEBUG(dbgs() << "LV: Not vectorizing: Cannot prove legality.\n");
98179817
Hints.emitRemarkWithHints();
@@ -10248,6 +10248,7 @@ PreservedAnalyses LoopVectorizePass::run(Function &F,
1024810248
DB = &AM.getResult<DemandedBitsAnalysis>(F);
1024910249
ORE = &AM.getResult<OptimizationRemarkEmitterAnalysis>(F);
1025010250
LAIs = &AM.getResult<LoopAccessAnalysis>(F);
10251+
AA = &AM.getResult<AAManager>(F);
1025110252

1025210253
auto &MAMProxy = AM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
1025310254
PSI = MAMProxy.getCachedResult<ProfileSummaryAnalysis>(*F.getParent());

0 commit comments

Comments
 (0)