@@ -689,7 +689,7 @@ RecurrenceDescriptor::isAnyOfPattern(Loop *Loop, PHINode *OrigPhi,
689689// reduction operations.
690690RecurrenceDescriptor::InstDesc
691691RecurrenceDescriptor::isFindLastIVPattern (PHINode *OrigPhi, Instruction *I,
692- ScalarEvolution * SE) {
692+ ScalarEvolution & SE) {
693693 // Only match select with single use cmp condition.
694694 // TODO: Only handle single use for now.
695695 CmpInst::Predicate Pred;
@@ -708,22 +708,19 @@ RecurrenceDescriptor::isFindLastIVPattern(PHINode *OrigPhi, Instruction *I,
708708 return InstDesc (false , I);
709709
710710 auto IsIncreasingLoopInduction = [&](Value *V) {
711- if (!SE)
712- return false ;
713-
714711 Type *Ty = V->getType ();
715- if (!SE-> isSCEVable (Ty))
712+ if (!SE. isSCEVable (Ty))
716713 return false ;
717714
718- auto *AR = dyn_cast<SCEVAddRecExpr>(SE-> getSCEV (V));
715+ auto *AR = dyn_cast<SCEVAddRecExpr>(SE. getSCEV (V));
719716 if (!AR)
720717 return false ;
721718
722- const SCEV *Step = AR->getStepRecurrence (* SE);
723- if (!SE-> isKnownPositive (Step))
719+ const SCEV *Step = AR->getStepRecurrence (SE);
720+ if (!SE. isKnownPositive (Step))
724721 return false ;
725722
726- const ConstantRange IVRange = SE-> getSignedRange (AR);
723+ const ConstantRange IVRange = SE. getSignedRange (AR);
727724 unsigned NumBits = Ty->getIntegerBitWidth ();
728725 // Keep the minimum value of the recurrence type as the sentinel value.
729726 // The maximum acceptable range for the increasing induction variable,
@@ -880,8 +877,8 @@ RecurrenceDescriptor::InstDesc RecurrenceDescriptor::isRecurrenceInstr(
880877 if (Kind == RecurKind::FAdd || Kind == RecurKind::FMul ||
881878 Kind == RecurKind::Add || Kind == RecurKind::Mul)
882879 return isConditionalRdxPattern (Kind, I);
883- if (isFindLastIVRecurrenceKind (Kind))
884- return isFindLastIVPattern (OrigPhi, I, SE);
880+ if (isFindLastIVRecurrenceKind (Kind) && SE )
881+ return isFindLastIVPattern (OrigPhi, I, * SE);
885882 [[fallthrough]];
886883 case Instruction::FCmp:
887884 case Instruction::ICmp:
0 commit comments