@@ -691,7 +691,7 @@ RecurrenceDescriptor::isAnyOfPattern(Loop *Loop, PHINode *OrigPhi,
691691// reduction operations.
692692RecurrenceDescriptor::InstDesc
693693RecurrenceDescriptor::isFindLastIVPattern (PHINode *OrigPhi, Instruction *I,
694- ScalarEvolution * SE) {
694+ ScalarEvolution & SE) {
695695 // Only match select with single use cmp condition.
696696 // TODO: Only handle single use for now.
697697 CmpInst::Predicate Pred;
@@ -710,22 +710,19 @@ RecurrenceDescriptor::isFindLastIVPattern(PHINode *OrigPhi, Instruction *I,
710710 return InstDesc (false , I);
711711
712712 auto IsIncreasingLoopInduction = [&](Value *V) {
713- if (!SE)
714- return false ;
715-
716713 Type *Ty = V->getType ();
717- if (!SE-> isSCEVable (Ty))
714+ if (!SE. isSCEVable (Ty))
718715 return false ;
719716
720- auto *AR = dyn_cast<SCEVAddRecExpr>(SE-> getSCEV (V));
717+ auto *AR = dyn_cast<SCEVAddRecExpr>(SE. getSCEV (V));
721718 if (!AR)
722719 return false ;
723720
724- const SCEV *Step = AR->getStepRecurrence (* SE);
725- if (!SE-> isKnownPositive (Step))
721+ const SCEV *Step = AR->getStepRecurrence (SE);
722+ if (!SE. isKnownPositive (Step))
726723 return false ;
727724
728- const ConstantRange IVRange = SE-> getSignedRange (AR);
725+ const ConstantRange IVRange = SE. getSignedRange (AR);
729726 unsigned NumBits = Ty->getIntegerBitWidth ();
730727 // Keep the minimum value of the recurrence type as the sentinel value.
731728 // The maximum acceptable range for the increasing induction variable,
@@ -887,8 +884,8 @@ RecurrenceDescriptor::InstDesc RecurrenceDescriptor::isRecurrenceInstr(
887884 if (Kind == RecurKind::FAdd || Kind == RecurKind::FMul ||
888885 Kind == RecurKind::Add || Kind == RecurKind::Mul)
889886 return isConditionalRdxPattern (Kind, I);
890- if (isFindLastIVRecurrenceKind (Kind))
891- return isFindLastIVPattern (OrigPhi, I, SE);
887+ if (isFindLastIVRecurrenceKind (Kind) && SE )
888+ return isFindLastIVPattern (OrigPhi, I, * SE);
892889 [[fallthrough]];
893890 case Instruction::FCmp:
894891 case Instruction::ICmp:
0 commit comments