[llvm] [LoopVectorize] In LoopVectorize.cpp start using getSymbolicMaxBackedgeTakenCount (PR #108833)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 16 07:16:29 PDT 2024
https://github.com/david-arm created https://github.com/llvm/llvm-project/pull/108833
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.
>From e0dc97f3ce5c16586720bc72be801e8bf9f9f64e Mon Sep 17 00:00:00 2001
From: David Sherwood <david.sherwood at arm.com>
Date: Mon, 16 Sep 2024 14:09:02 +0000
Subject: [PATCH] [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.
---
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index f726b171969a30..5ab0fd12c538f3 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -907,7 +907,7 @@ Value *getRuntimeVF(IRBuilderBase &B, Type *Ty, ElementCount VF) {
const SCEV *createTripCountSCEV(Type *IdxTy, PredicatedScalarEvolution &PSE,
Loop *OrigLoop) {
- const SCEV *BackedgeTakenCount = PSE.getBackedgeTakenCount();
+ const SCEV *BackedgeTakenCount = PSE.getSymbolicMaxBackedgeTakenCount();
assert(!isa<SCEVCouldNotCompute>(BackedgeTakenCount) && "Invalid loop count");
ScalarEvolution &SE = *PSE.getSE();
@@ -4090,7 +4090,7 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) {
unsigned MaxVFtimesIC =
UserIC ? *MaxPowerOf2RuntimeVF * UserIC : *MaxPowerOf2RuntimeVF;
ScalarEvolution *SE = PSE.getSE();
- const SCEV *BackedgeTakenCount = PSE.getBackedgeTakenCount();
+ const SCEV *BackedgeTakenCount = PSE.getSymbolicMaxBackedgeTakenCount();
const SCEV *ExitCount = SE->getAddExpr(
BackedgeTakenCount, SE->getOne(BackedgeTakenCount->getType()));
const SCEV *Rem = SE->getURemExpr(
@@ -9584,7 +9584,7 @@ static bool processLoopInVPlanNativePath(
ProfileSummaryInfo *PSI, LoopVectorizeHints &Hints,
LoopVectorizationRequirements &Requirements) {
- if (isa<SCEVCouldNotCompute>(PSE.getBackedgeTakenCount())) {
+ if (isa<SCEVCouldNotCompute>(PSE.getSymbolicMaxBackedgeTakenCount())) {
LLVM_DEBUG(dbgs() << "LV: cannot compute the outer-loop trip count\n");
return false;
}
More information about the llvm-commits
mailing list