@@ -151,7 +151,7 @@ class InductiveRangeCheck {
151151
152152 const SCEV *Offset = nullptr ;
153153 const SCEV *Scale = nullptr ;
154- Value *Length = nullptr ;
154+ const SCEV *Length = nullptr ;
155155 Use *CheckUse = nullptr ;
156156 RangeCheckKind Kind = RANGE_CHECK_UNKNOWN;
157157 bool IsSigned = true ;
@@ -168,7 +168,7 @@ class InductiveRangeCheck {
168168public:
169169 const SCEV *getOffset () const { return Offset; }
170170 const SCEV *getScale () const { return Scale; }
171- Value *getLength () const { return Length; }
171+ const SCEV *getLength () const { return Length; }
172172 bool isSigned () const { return IsSigned; }
173173
174174 void print (raw_ostream &OS) const {
@@ -419,7 +419,7 @@ void InductiveRangeCheck::extractRangeChecksFromCond(
419419 return ;
420420
421421 InductiveRangeCheck IRC;
422- IRC.Length = Length;
422+ IRC.Length = Length ? SE. getSCEV (Length) : nullptr ;
423423 IRC.Offset = IndexAddRec->getStart ();
424424 IRC.Scale = IndexAddRec->getStepRecurrence (SE);
425425 IRC.CheckUse = &ConditionUse;
@@ -1660,9 +1660,9 @@ InductiveRangeCheck::computeSafeIterationSpace(
16601660
16611661 // We strengthen "0 <= I" to "0 <= I < INT_SMAX" and "I < L" to "0 <= I < L".
16621662 // We can potentially do much better here.
1663- if (Value *V = getLength ()) {
1664- UpperLimit = SE. getSCEV (V) ;
1665- } else {
1663+ if (const SCEV *L = getLength ())
1664+ UpperLimit = L ;
1665+ else {
16661666 assert (Kind == InductiveRangeCheck::RANGE_CHECK_LOWER && " invariant!" );
16671667 unsigned BitWidth = cast<IntegerType>(IndVar->getType ())->getBitWidth ();
16681668 UpperLimit = SE.getConstant (APInt::getSignedMaxValue (BitWidth));
0 commit comments