Skip to content

Commit a431402

Browse files
committed
[LV] Remove loop arg from CM::isCandidateForEpilogueVectorization (NFC)
LVP operates on the loop it stores in TheLoop. Use it instead of the argument, to be in line with other member functions. Suggested as independent improvement in D143938.
1 parent 6fa07a8 commit a431402

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,10 +1844,9 @@ class LoopVectorizationCostModel {
18441844
Ops, [this, VF](Value *V) { return this->needsExtract(V, VF); }));
18451845
}
18461846

1847-
/// Determines if we have the infrastructure to vectorize loop \p L and its
1847+
/// Determines if we have the infrastructure to vectorize the loop and its
18481848
/// epilogue, assuming the main loop is vectorized by \p VF.
1849-
bool isCandidateForEpilogueVectorization(const Loop &L,
1850-
const ElementCount VF) const;
1849+
bool isCandidateForEpilogueVectorization(const ElementCount VF) const;
18511850

18521851
/// Returns true if epilogue vectorization is considered profitable, and
18531852
/// false otherwise.
@@ -5555,31 +5554,32 @@ VectorizationFactor LoopVectorizationCostModel::selectVectorizationFactor(
55555554
}
55565555

55575556
bool LoopVectorizationCostModel::isCandidateForEpilogueVectorization(
5558-
const Loop &L, ElementCount VF) const {
5557+
ElementCount VF) const {
55595558
// Cross iteration phis such as reductions need special handling and are
55605559
// currently unsupported.
5561-
if (any_of(L.getHeader()->phis(),
5560+
if (any_of(TheLoop->getHeader()->phis(),
55625561
[&](PHINode &Phi) { return Legal->isFixedOrderRecurrence(&Phi); }))
55635562
return false;
55645563

55655564
// Phis with uses outside of the loop require special handling and are
55665565
// currently unsupported.
55675566
for (const auto &Entry : Legal->getInductionVars()) {
55685567
// Look for uses of the value of the induction at the last iteration.
5569-
Value *PostInc = Entry.first->getIncomingValueForBlock(L.getLoopLatch());
5568+
Value *PostInc =
5569+
Entry.first->getIncomingValueForBlock(TheLoop->getLoopLatch());
55705570
for (User *U : PostInc->users())
5571-
if (!L.contains(cast<Instruction>(U)))
5571+
if (!TheLoop->contains(cast<Instruction>(U)))
55725572
return false;
55735573
// Look for uses of penultimate value of the induction.
55745574
for (User *U : Entry.first->users())
5575-
if (!L.contains(cast<Instruction>(U)))
5575+
if (!TheLoop->contains(cast<Instruction>(U)))
55765576
return false;
55775577
}
55785578

55795579
// Epilogue vectorization code has not been auditted to ensure it handles
55805580
// non-latch exits properly. It may be fine, but it needs auditted and
55815581
// tested.
5582-
if (L.getExitingBlock() != L.getLoopLatch())
5582+
if (TheLoop->getExitingBlock() != TheLoop->getLoopLatch())
55835583
return false;
55845584

55855585
return true;
@@ -5626,7 +5626,7 @@ LoopVectorizationCostModel::selectEpilogueVectorizationFactor(
56265626

56275627
// Not really a cost consideration, but check for unsupported cases here to
56285628
// simplify the logic.
5629-
if (!isCandidateForEpilogueVectorization(*TheLoop, MainLoopVF)) {
5629+
if (!isCandidateForEpilogueVectorization(MainLoopVF)) {
56305630
LLVM_DEBUG(dbgs() << "LEV: Unable to vectorize epilogue because the loop "
56315631
"is not a supported candidate.\n");
56325632
return Result;

0 commit comments

Comments
 (0)