Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 5d03e9f

Browse files
author
Max Kazantsev
committed
[IRCE][NFC] Store Length as SCEV in RangeCheck instead of Value
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316889 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent c021b1e commit 5d03e9f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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 {
168168
public:
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));

test/Transforms/IRCE/only-upper-check.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
; CHECK: irce: loop has 1 inductive range checks:
44
; CHECK-NEXT:InductiveRangeCheck:
55
; CHECK-NEXT: Kind: RANGE_CHECK_UPPER
6-
; CHECK-NEXT: Offset: %offset Scale: 1 Length: %len = load i32, i32* %a_len_ptr, !range !0
6+
; CHECK-NEXT: Offset: %offset Scale: 1 Length: %len
77
; CHECK-NEXT: CheckUse: br i1 %abc, label %in.bounds, label %out.of.bounds, !prof !1 Operand: 0
88
; CHECK-NEXT: irce: in function incrementing: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
99

0 commit comments

Comments
 (0)