-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[VPlan] Manage Sentinel value for FindLastIV in VPlan. #142291
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
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 |
---|---|---|
|
@@ -7266,9 +7266,11 @@ static void fixReductionScalarResumeWhenVectorizingEpilog( | |
using namespace llvm::PatternMatch; | ||
Value *Cmp, *OrigResumeV, *CmpOp; | ||
bool IsExpectedPattern = | ||
match(MainResumeValue, m_Select(m_OneUse(m_Value(Cmp)), | ||
m_Specific(RdxDesc.getSentinelValue()), | ||
m_Value(OrigResumeV))) && | ||
match(MainResumeValue, | ||
m_Select( | ||
m_OneUse(m_Value(Cmp)), | ||
m_Specific(EpiRedResult->getOperand(2)->getLiveInIRValue()), | ||
m_Value(OrigResumeV))) && | ||
(match(Cmp, m_SpecificICmp(ICmpInst::ICMP_EQ, m_Specific(OrigResumeV), | ||
m_Value(CmpOp))) && | ||
((CmpOp == StartV && isGuaranteedNotToBeUndefOrPoison(CmpOp)))); | ||
|
@@ -9235,9 +9237,11 @@ void LoopVectorizationPlanner::adjustRecipesForReductions( | |
if (RecurrenceDescriptor::isFindLastIVRecurrenceKind( | ||
RdxDesc.getRecurrenceKind())) { | ||
VPValue *Start = PhiR->getStartValue(); | ||
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.
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. Done thanks |
||
FinalReductionResult = | ||
Builder.createNaryOp(VPInstruction::ComputeFindLastIVResult, | ||
{PhiR, Start, NewExitingVPV}, ExitDL); | ||
FinalReductionResult = Builder.createNaryOp( | ||
VPInstruction::ComputeFindLastIVResult, | ||
{PhiR, Start, Plan->getOrAddLiveIn(RdxDesc.getSentinelValue()), | ||
NewExitingVPV}, | ||
ExitDL); | ||
} else if (RecurrenceDescriptor::isAnyOfRecurrenceKind( | ||
RdxDesc.getRecurrenceKind())) { | ||
VPValue *Start = PhiR->getStartValue(); | ||
|
@@ -9825,8 +9829,8 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L, | |
BasicBlock *ResumeBB = cast<Instruction>(ResumeV)->getParent(); | ||
IRBuilder<> Builder(ResumeBB, ResumeBB->getFirstNonPHIIt()); | ||
Value *Cmp = Builder.CreateICmpEQ(ResumeV, ToFrozen[StartV]); | ||
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.
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. Done thanks |
||
ResumeV = | ||
Builder.CreateSelect(Cmp, RdxDesc.getSentinelValue(), ResumeV); | ||
ResumeV = Builder.CreateSelect( | ||
Cmp, RdxResult->getOperand(2)->getLiveInIRValue(), ResumeV); | ||
} else { | ||
VPValue *StartVal = Plan.getOrAddLiveIn(ResumeV); | ||
auto *PhiR = dyn_cast<VPReductionPHIRecipe>(&R); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -645,16 +645,16 @@ Value *VPInstruction::generate(VPTransformState &State) { | |
|
||
// The recipe's operands are the reduction phi, followed by one operand for | ||
// each part of the reduction. | ||
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. Comment needs updating? Operands better be explaining under /// somewhere? 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. Done thanks |
||
unsigned UF = getNumOperands() - 2; | ||
Value *ReducedPartRdx = State.get(getOperand(2)); | ||
unsigned UF = getNumOperands() - 3; | ||
Value *ReducedPartRdx = State.get(getOperand(3)); | ||
for (unsigned Part = 1; Part < UF; ++Part) { | ||
ReducedPartRdx = createMinMaxOp(Builder, RecurKind::SMax, ReducedPartRdx, | ||
State.get(getOperand(2 + Part))); | ||
State.get(getOperand(3 + Part))); | ||
} | ||
|
||
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.
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. Done, also for Start |
||
return createFindLastIVReduction(Builder, ReducedPartRdx, | ||
State.get(getOperand(1), true), | ||
RdxDesc.getSentinelValue()); | ||
getOperand(2)->getLiveInIRValue()); | ||
} | ||
case VPInstruction::ComputeReductionResult: { | ||
// FIXME: The cross-recipe dependency on VPReductionPHIRecipe is temporary | ||
|
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.
Value *Sentinel = EpiRedResult->getOperand(2)->getLiveInIRValue();
Perhaps worth a
Value *vputils::getSentinel(VPInstruction*)
?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.
Done, thanks!