Skip to content

Commit 952b5df

Browse files
committed
Fix SE pass
1 parent 72347e2 commit 952b5df

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

llvm/include/llvm/Analysis/IVDescriptors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class RecurrenceDescriptor {
167167
// TODO: FindLast does not need be restricted to increasing loop induction
168168
// variables.
169169
static InstDesc isFindLastIVPattern(PHINode *OrigPhi, Instruction *I,
170-
ScalarEvolution *SE);
170+
ScalarEvolution &SE);
171171

172172
/// Returns a struct describing if the instruction is a
173173
/// Select(FCmp(X, Y), (Z = X op PHINode), PHINode) instruction pattern.

llvm/lib/Analysis/IVDescriptors.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ RecurrenceDescriptor::isAnyOfPattern(Loop *Loop, PHINode *OrigPhi,
691691
// reduction operations.
692692
RecurrenceDescriptor::InstDesc
693693
RecurrenceDescriptor::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

Comments
 (0)