@@ -688,8 +688,8 @@ RecurrenceDescriptor::isAnyOfPattern(Loop *Loop, PHINode *OrigPhi,
688
688
// value of the data type or a non-constant value by using mask and multiple
689
689
// reduction operations.
690
690
RecurrenceDescriptor::InstDesc
691
- RecurrenceDescriptor::isFindLastIVPattern (PHINode *OrigPhi, Instruction *I ,
692
- ScalarEvolution &SE) {
691
+ RecurrenceDescriptor::isFindLastIVPattern (Loop *TheLoop, PHINode *OrigPhi ,
692
+ Instruction *I, ScalarEvolution &SE) {
693
693
// TODO: Support the vectorization of FindLastIV when the reduction phi is
694
694
// used by more than one select instruction. This vectorization is only
695
695
// performed when the SCEV of each increasing induction variable used by the
@@ -711,7 +711,7 @@ RecurrenceDescriptor::isFindLastIVPattern(PHINode *OrigPhi, Instruction *I,
711
711
return false ;
712
712
713
713
auto *AR = dyn_cast<SCEVAddRecExpr>(SE.getSCEV (V));
714
- if (!AR)
714
+ if (!AR || AR-> getLoop () != TheLoop )
715
715
return false ;
716
716
717
717
const SCEV *Step = AR->getStepRecurrence (SE);
@@ -880,7 +880,7 @@ RecurrenceDescriptor::InstDesc RecurrenceDescriptor::isRecurrenceInstr(
880
880
Kind == RecurKind::Add || Kind == RecurKind::Mul)
881
881
return isConditionalRdxPattern (Kind, I);
882
882
if (isFindLastIVRecurrenceKind (Kind) && SE)
883
- return isFindLastIVPattern (OrigPhi, I, *SE);
883
+ return isFindLastIVPattern (L, OrigPhi, I, *SE);
884
884
[[fallthrough]];
885
885
case Instruction::FCmp:
886
886
case Instruction::ICmp:
0 commit comments