Skip to content

Commit e0dc97f

Browse files
committed
[LoopVectorize] In LoopVectorize start using getSymbolicMaxBackedgeTakenCount
LoopVectorizationLegality currently only treats a loop as legal to vectorise if PredicatedScalarEvolution::getBackedgeTakenCount returns a valid SCEV, or more precisely that the loop must have an exact backedge taken count. Therefore, in LoopVectorize.cpp we can safely replace all calls to getBackedgeTakenCount with calls to getSymbolicMaxBackedgeTakenCount, since the result is the same. This also helps prepare the loop vectoriser for PR #88385.
1 parent f3029b3 commit e0dc97f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ Value *getRuntimeVF(IRBuilderBase &B, Type *Ty, ElementCount VF) {
907907

908908
const SCEV *createTripCountSCEV(Type *IdxTy, PredicatedScalarEvolution &PSE,
909909
Loop *OrigLoop) {
910-
const SCEV *BackedgeTakenCount = PSE.getBackedgeTakenCount();
910+
const SCEV *BackedgeTakenCount = PSE.getSymbolicMaxBackedgeTakenCount();
911911
assert(!isa<SCEVCouldNotCompute>(BackedgeTakenCount) && "Invalid loop count");
912912

913913
ScalarEvolution &SE = *PSE.getSE();
@@ -4090,7 +4090,7 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) {
40904090
unsigned MaxVFtimesIC =
40914091
UserIC ? *MaxPowerOf2RuntimeVF * UserIC : *MaxPowerOf2RuntimeVF;
40924092
ScalarEvolution *SE = PSE.getSE();
4093-
const SCEV *BackedgeTakenCount = PSE.getBackedgeTakenCount();
4093+
const SCEV *BackedgeTakenCount = PSE.getSymbolicMaxBackedgeTakenCount();
40944094
const SCEV *ExitCount = SE->getAddExpr(
40954095
BackedgeTakenCount, SE->getOne(BackedgeTakenCount->getType()));
40964096
const SCEV *Rem = SE->getURemExpr(
@@ -9584,7 +9584,7 @@ static bool processLoopInVPlanNativePath(
95849584
ProfileSummaryInfo *PSI, LoopVectorizeHints &Hints,
95859585
LoopVectorizationRequirements &Requirements) {
95869586

9587-
if (isa<SCEVCouldNotCompute>(PSE.getBackedgeTakenCount())) {
9587+
if (isa<SCEVCouldNotCompute>(PSE.getSymbolicMaxBackedgeTakenCount())) {
95889588
LLVM_DEBUG(dbgs() << "LV: cannot compute the outer-loop trip count\n");
95899589
return false;
95909590
}

0 commit comments

Comments
 (0)