@@ -7263,14 +7263,13 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
7263
7263
} else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (
7264
7264
RdxDesc.getRecurrenceKind ())) {
7265
7265
Value *StartV = getStartValueFromReductionResult (EpiRedResult);
7266
+ Value *SentinelV = EpiRedResult->getOperand (2 )->getLiveInIRValue ();
7266
7267
using namespace llvm ::PatternMatch;
7267
7268
Value *Cmp, *OrigResumeV, *CmpOp;
7268
7269
bool IsExpectedPattern =
7269
7270
match (MainResumeValue,
7270
- m_Select (
7271
- m_OneUse (m_Value (Cmp)),
7272
- m_Specific (EpiRedResult->getOperand (2 )->getLiveInIRValue ()),
7273
- m_Value (OrigResumeV))) &&
7271
+ m_Select (m_OneUse (m_Value (Cmp)), m_Specific (SentinelV),
7272
+ m_Value (OrigResumeV))) &&
7274
7273
(match (Cmp, m_SpecificICmp (ICmpInst::ICMP_EQ, m_Specific (OrigResumeV),
7275
7274
m_Value (CmpOp))) &&
7276
7275
((CmpOp == StartV && isGuaranteedNotToBeUndefOrPoison (CmpOp))));
@@ -9224,11 +9223,10 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9224
9223
if (RecurrenceDescriptor::isFindLastIVRecurrenceKind (
9225
9224
RdxDesc.getRecurrenceKind ())) {
9226
9225
VPValue *Start = PhiR->getStartValue ();
9227
- FinalReductionResult = Builder.createNaryOp (
9228
- VPInstruction::ComputeFindLastIVResult,
9229
- {PhiR, Start, Plan->getOrAddLiveIn (RdxDesc.getSentinelValue ()),
9230
- NewExitingVPV},
9231
- ExitDL);
9226
+ VPValue *Sentinel = Plan->getOrAddLiveIn (RdxDesc.getSentinelValue ());
9227
+ FinalReductionResult =
9228
+ Builder.createNaryOp (VPInstruction::ComputeFindLastIVResult,
9229
+ {PhiR, Start, Sentinel, NewExitingVPV}, ExitDL);
9232
9230
} else if (RecurrenceDescriptor::isAnyOfRecurrenceKind (
9233
9231
RdxDesc.getRecurrenceKind ())) {
9234
9232
VPValue *Start = PhiR->getStartValue ();
@@ -9816,8 +9814,8 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
9816
9814
BasicBlock *ResumeBB = cast<Instruction>(ResumeV)->getParent ();
9817
9815
IRBuilder<> Builder (ResumeBB, ResumeBB->getFirstNonPHIIt ());
9818
9816
Value *Cmp = Builder.CreateICmpEQ (ResumeV, ToFrozen[StartV]);
9819
- ResumeV = Builder. CreateSelect (
9820
- Cmp, RdxResult-> getOperand ( 2 )-> getLiveInIRValue () , ResumeV);
9817
+ Value *Sentinel = RdxResult-> getOperand ( 2 )-> getLiveInIRValue ();
9818
+ ResumeV = Builder. CreateSelect ( Cmp, Sentinel , ResumeV);
9821
9819
} else {
9822
9820
VPValue *StartVal = Plan.getOrAddLiveIn (ResumeV);
9823
9821
auto *PhiR = dyn_cast<VPReductionPHIRecipe>(&R);
0 commit comments