-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[VPlan] Add getSCEVExprForVPValue util, use to get trip count SCEV (NFC) #94464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fcd4148
c777a3a
d7d389e
4d0f112
9bc1413
dbe22b4
8449f8f
ca98f41
3f72966
cc75e4a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -685,10 +685,11 @@ void VPlanTransforms::optimizeForVFAndUF(VPlan &Plan, ElementCount BestVF, | |
m_BranchOnCond(m_Not(m_ActiveLaneMask(m_VPValue(), m_VPValue()))))) | ||
return; | ||
|
||
Type *IdxTy = | ||
Plan.getCanonicalIV()->getStartValue()->getLiveInIRValue()->getType(); | ||
const SCEV *TripCount = createTripCountSCEV(IdxTy, PSE); | ||
ScalarEvolution &SE = *PSE.getSE(); | ||
const SCEV *TripCount = | ||
vputils::getSCEVExprForVPValue(Plan.getTripCount(), SE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW, independently - BOC below would better use an unconditional branch than BranchOnCond with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, will also entail to remove the region and header phis. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Worth asserting that the SCEV returned could be computed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, added assert. |
||
assert(!isa<SCEVCouldNotCompute>(TripCount) && | ||
"Trip count SCEV must be computable"); | ||
ElementCount NumElements = BestVF.multiplyCoefficientBy(BestUF); | ||
const SCEV *C = SE.getElementCount(TripCount->getType(), NumElements); | ||
if (TripCount->isZero() || | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
#include "VPlanUtils.h" | ||
#include "VPlanPatternMatch.h" | ||
#include "llvm/ADT/TypeSwitch.h" | ||
#include "llvm/Analysis/ScalarEvolutionExpressions.h" | ||
|
||
using namespace llvm; | ||
|
@@ -60,3 +61,14 @@ bool vputils::isHeaderMask(const VPValue *V, VPlan &Plan) { | |
return match(V, m_Binary<Instruction::ICmp>(m_VPValue(A), m_VPValue(B))) && | ||
IsWideCanonicalIV(A) && B == Plan.getOrCreateBackedgeTakenCount(); | ||
} | ||
|
||
const SCEV *vputils::getSCEVExprForVPValue(VPValue *V, ScalarEvolution &SE) { | ||
if (V->isLiveIn()) | ||
return SE.getSCEV(V->getLiveInIRValue()); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to work well for Values at VPlan's boundary: can complement live-ins with live-out/VPIRInstructions which could also simply retrieve SE.getSCEV() of the instruction they wrap; as follow-up, along with concrete use. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep |
||
// TODO: Support constructing SCEVs for more recipes as needed. | ||
return TypeSwitch<const VPRecipeBase *, const SCEV *>(V->getDefiningRecipe()) | ||
.Case<VPExpandSCEVRecipe>( | ||
[](const VPExpandSCEVRecipe *R) { return R->getSCEV(); }) | ||
.Default([&SE](const VPRecipeBase *) { return SE.getCouldNotCompute(); }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would be good to explain what
IdxTy
stands for, and/or use a more descriptive name.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to
InductionTy
and documented, thanks!