Skip to content

Commit 4a5edea

Browse files
committed
[SCEV] Use both known bits and sign bits when computing range of SCEV unknowns
When computing a range for a SCEVUnknown, today we use computeKnownBits for unsigned ranges, and computeNumSignBots for signed ranges. This means we miss opportunities to improve range results. One common missed pattern is that we have a signed range of a value which CKB can determine is positive, but CNSB doesn't convey that information. The current range includes the negative part, and is thus double the size. Per the removed comment, the original concern which delayed using both (after some code merging years back) was a compile time concern. CTMark results (provided by Nikita, thanks!) showed a geomean impact of about 0.1%. This doesn't seem large enough to avoid higher quality results. Differential Revision: https://reviews.llvm.org/D96534
1 parent bcb5a12 commit 4a5edea

13 files changed

+79
-84
lines changed

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5843,39 +5843,34 @@ ScalarEvolution::getRangeRef(const SCEV *S,
58435843
ConservativeResult = ConservativeResult.intersectWith(MDRange.getValue(),
58445844
RangeType);
58455845

5846-
// Split here to avoid paying the compile-time cost of calling both
5847-
// computeKnownBits and ComputeNumSignBits. This restriction can be lifted
5848-
// if needed.
5846+
// See if ValueTracking can give us a useful range.
58495847
const DataLayout &DL = getDataLayout();
5850-
if (SignHint == ScalarEvolution::HINT_RANGE_UNSIGNED) {
5851-
// For a SCEVUnknown, ask ValueTracking.
5852-
KnownBits Known = computeKnownBits(U->getValue(), DL, 0, &AC, nullptr, &DT);
5853-
if (Known.getBitWidth() != BitWidth)
5854-
Known = Known.zextOrTrunc(BitWidth);
5855-
// If Known does not result in full-set, intersect with it.
5856-
if (Known.getMinValue() != Known.getMaxValue() + 1)
5857-
ConservativeResult = ConservativeResult.intersectWith(
5858-
ConstantRange(Known.getMinValue(), Known.getMaxValue() + 1),
5859-
RangeType);
5860-
} else {
5861-
assert(SignHint == ScalarEvolution::HINT_RANGE_SIGNED &&
5862-
"generalize as needed!");
5863-
unsigned NS = ComputeNumSignBits(U->getValue(), DL, 0, &AC, nullptr, &DT);
5864-
// If the pointer size is larger than the index size type, this can cause
5865-
// NS to be larger than BitWidth. So compensate for this.
5866-
if (U->getType()->isPointerTy()) {
5867-
unsigned ptrSize = DL.getPointerTypeSizeInBits(U->getType());
5868-
int ptrIdxDiff = ptrSize - BitWidth;
5869-
if (ptrIdxDiff > 0 && ptrSize > BitWidth && NS > (unsigned)ptrIdxDiff)
5870-
NS -= ptrIdxDiff;
5871-
}
5872-
5873-
if (NS > 1)
5874-
ConservativeResult = ConservativeResult.intersectWith(
5875-
ConstantRange(APInt::getSignedMinValue(BitWidth).ashr(NS - 1),
5876-
APInt::getSignedMaxValue(BitWidth).ashr(NS - 1) + 1),
5877-
RangeType);
5878-
}
5848+
KnownBits Known = computeKnownBits(U->getValue(), DL, 0, &AC, nullptr, &DT);
5849+
if (Known.getBitWidth() != BitWidth)
5850+
Known = Known.zextOrTrunc(BitWidth);
5851+
// If Known does not result in full-set, intersect with it.
5852+
if (Known.getMinValue() != Known.getMaxValue() + 1)
5853+
ConservativeResult = ConservativeResult.intersectWith(
5854+
ConstantRange(Known.getMinValue(), Known.getMaxValue() + 1),
5855+
RangeType);
5856+
5857+
// ValueTracking may be able to compute a tighter result for the number of
5858+
// sign bits than for the value of those sign bits.
5859+
unsigned NS = ComputeNumSignBits(U->getValue(), DL, 0, &AC, nullptr, &DT);
5860+
// If the pointer size is larger than the index size type, this can cause
5861+
// NS to be larger than BitWidth. So compensate for this.
5862+
if (U->getType()->isPointerTy()) {
5863+
unsigned ptrSize = DL.getPointerTypeSizeInBits(U->getType());
5864+
int ptrIdxDiff = ptrSize - BitWidth;
5865+
if (ptrIdxDiff > 0 && ptrSize > BitWidth && NS > (unsigned)ptrIdxDiff)
5866+
NS -= ptrIdxDiff;
5867+
}
5868+
5869+
if (NS > 1)
5870+
ConservativeResult = ConservativeResult.intersectWith(
5871+
ConstantRange(APInt::getSignedMinValue(BitWidth).ashr(NS - 1),
5872+
APInt::getSignedMaxValue(BitWidth).ashr(NS - 1) + 1),
5873+
RangeType);
58795874

58805875
// A range of Phi is a subset of union of all ranges of its input.
58815876
if (const PHINode *Phi = dyn_cast<PHINode>(U->getValue())) {

llvm/test/Analysis/ScalarEvolution/add-expr-pointer-operand-sorting.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ define i32 @d(i32 %base) {
3737
; CHECK-NEXT: %sub.ptr.sub = sub i64 %sub.ptr.lhs.cast, ptrtoint ([1 x i32]* @b to i64)
3838
; CHECK-NEXT: --> ((-1 * (ptrtoint [1 x i32]* @b to i64)) + (ptrtoint i32* %1 to i64)) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
3939
; CHECK-NEXT: %sub.ptr.div = sdiv exact i64 %sub.ptr.sub, 4
40-
; CHECK-NEXT: --> %sub.ptr.div U: full-set S: [-2305843009213693952,2305843009213693952) Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
40+
; CHECK-NEXT: --> %sub.ptr.div U: [-2305843009213693952,2305843009213693952) S: [-2305843009213693952,2305843009213693952) Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
4141
; CHECK-NEXT: %arrayidx1 = getelementptr inbounds [1 x i8], [1 x i8]* %arrayidx, i64 0, i64 %sub.ptr.div
4242
; CHECK-NEXT: --> ({((sext i32 %base to i64) + %e),+,1}<nw><%for.cond> + %sub.ptr.div) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
4343
; CHECK-NEXT: %2 = load i8, i8* %arrayidx1, align 1

llvm/test/Analysis/ScalarEvolution/ashr.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ define i32 @t2(i32 %x, i32 %y) {
3131
; CHECK-LABEL: 't2'
3232
; CHECK-NEXT: Classifying expressions for: @t2
3333
; CHECK-NEXT: %i0 = ashr i32 %x, 4
34-
; CHECK-NEXT: --> %i0 U: full-set S: [-134217728,134217728)
34+
; CHECK-NEXT: --> %i0 U: [-134217728,134217728) S: [-134217728,134217728)
3535
; CHECK-NEXT: Determining loop execution counts for: @t2
3636
;
3737
%i0 = ashr i32 %x, 4

llvm/test/Analysis/ScalarEvolution/extract-highbits-sameconstmask.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ define i32 @sdiv(i32 %val) nounwind {
2121
; CHECK-LABEL: 'sdiv'
2222
; CHECK-NEXT: Classifying expressions for: @sdiv
2323
; CHECK-NEXT: %tmp1 = sdiv i32 %val, 16
24-
; CHECK-NEXT: --> %tmp1 U: full-set S: [-134217728,134217728)
24+
; CHECK-NEXT: --> %tmp1 U: [-134217728,134217728) S: [-134217728,134217728)
2525
; CHECK-NEXT: %tmp2 = mul i32 %tmp1, 16
2626
; CHECK-NEXT: --> (16 * %tmp1)<nsw> U: [0,-15) S: [-2147483648,2147483633)
2727
; CHECK-NEXT: Determining loop execution counts for: @sdiv

llvm/test/Analysis/ScalarEvolution/increasing-or-decreasing-iv.ll

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ define void @f0(i1 %c) {
66
; CHECK-LABEL: 'f0'
77
; CHECK-NEXT: Classifying expressions for: @f0
88
; CHECK-NEXT: %start = select i1 %c, i32 127, i32 0
9-
; CHECK-NEXT: --> %start U: [0,128) S: [-128,128)
9+
; CHECK-NEXT: --> %start U: [0,128) S: [0,128)
1010
; CHECK-NEXT: %step = select i1 %c, i32 -1, i32 1
1111
; CHECK-NEXT: --> %step U: [1,0) S: [-2,2)
1212
; CHECK-NEXT: %loop.iv = phi i32 [ 0, %entry ], [ %loop.iv.inc, %loop ]
1313
; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,128) S: [0,128) Exits: 127 LoopDispositions: { %loop: Computable }
1414
; CHECK-NEXT: %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ]
1515
; CHECK-NEXT: --> {%start,+,%step}<%loop> U: [0,128) S: [0,128) Exits: ((127 * %step)<nsw> + %start) LoopDispositions: { %loop: Computable }
1616
; CHECK-NEXT: %iv.next = add i32 %iv, %step
17-
; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: [-384,256) S: [-384,256) Exits: ((128 * %step)<nsw> + %start) LoopDispositions: { %loop: Computable }
17+
; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: [-256,256) S: [-256,256) Exits: ((128 * %step)<nsw> + %start) LoopDispositions: { %loop: Computable }
1818
; CHECK-NEXT: %loop.iv.inc = add i32 %loop.iv, 1
1919
; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,129) S: [1,129) Exits: 128 LoopDispositions: { %loop: Computable }
2020
; CHECK-NEXT: Determining loop execution counts for: @f0
@@ -45,7 +45,7 @@ define void @f1(i1 %c) {
4545
; CHECK-LABEL: 'f1'
4646
; CHECK-NEXT: Classifying expressions for: @f1
4747
; CHECK-NEXT: %start = select i1 %c, i32 120, i32 0
48-
; CHECK-NEXT: --> %start U: [0,121) S: [-128,128)
48+
; CHECK-NEXT: --> %start U: [0,121) S: [0,121)
4949
; CHECK-NEXT: %step = select i1 %c, i32 -8, i32 8
5050
; CHECK-NEXT: --> %step U: [8,-7) S: [-16,16)
5151
; CHECK-NEXT: %loop.iv = phi i32 [ 0, %entry ], [ %loop.iv.inc, %loop ]
@@ -81,7 +81,7 @@ define void @f1(i1 %c) {
8181
; CHECK-NEXT: %iv.m7 = sub i32 %iv, 7
8282
; CHECK-NEXT: --> {(-7 + %start)<nsw>,+,%step}<%loop> U: [-7,114) S: [-7,114) Exits: (-7 + (15 * %step)<nsw> + %start) LoopDispositions: { %loop: Computable }
8383
; CHECK-NEXT: %iv.next = add i32 %iv, %step
84-
; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: [0,-7) S: [-384,368) Exits: ((16 * %step)<nsw> + %start) LoopDispositions: { %loop: Computable }
84+
; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: [0,-7) S: [-256,361) Exits: ((16 * %step)<nsw> + %start) LoopDispositions: { %loop: Computable }
8585
; CHECK-NEXT: %loop.iv.inc = add i32 %loop.iv, 1
8686
; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,17) S: [1,17) Exits: 16 LoopDispositions: { %loop: Computable }
8787
; CHECK-NEXT: Determining loop execution counts for: @f1
@@ -131,17 +131,17 @@ define void @f2(i1 %c) {
131131
; CHECK-LABEL: 'f2'
132132
; CHECK-NEXT: Classifying expressions for: @f2
133133
; CHECK-NEXT: %start = select i1 %c, i32 127, i32 0
134-
; CHECK-NEXT: --> %start U: [0,128) S: [-128,128)
134+
; CHECK-NEXT: --> %start U: [0,128) S: [0,128)
135135
; CHECK-NEXT: %step = select i1 %c, i32 -1, i32 1
136136
; CHECK-NEXT: --> %step U: [1,0) S: [-2,2)
137137
; CHECK-NEXT: %loop.iv = phi i32 [ 0, %entry ], [ %loop.iv.inc, %loop ]
138138
; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,128) S: [0,128) Exits: 127 LoopDispositions: { %loop: Computable }
139139
; CHECK-NEXT: %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ]
140140
; CHECK-NEXT: --> {%start,+,%step}<%loop> U: [0,128) S: [0,128) Exits: ((127 * %step)<nsw> + %start) LoopDispositions: { %loop: Computable }
141141
; CHECK-NEXT: %iv.sext = sext i32 %iv to i64
142-
; CHECK-NEXT: --> {(sext i32 %start to i64),+,(sext i32 %step to i64)}<nsw><%loop> U: [0,128) S: [0,128) Exits: ((sext i32 %start to i64) + (127 * (sext i32 %step to i64))<nsw>) LoopDispositions: { %loop: Computable }
142+
; CHECK-NEXT: --> {(zext i32 %start to i64),+,(sext i32 %step to i64)}<nsw><%loop> U: [0,128) S: [0,128) Exits: ((zext i32 %start to i64) + (127 * (sext i32 %step to i64))<nsw>) LoopDispositions: { %loop: Computable }
143143
; CHECK-NEXT: %iv.next = add i32 %iv, %step
144-
; CHECK-NEXT: --> {(%step + %start),+,%step}<nw><%loop> U: [-384,256) S: [-384,256) Exits: ((128 * %step)<nsw> + %start) LoopDispositions: { %loop: Computable }
144+
; CHECK-NEXT: --> {(%step + %start),+,%step}<nw><%loop> U: [-256,256) S: [-256,256) Exits: ((128 * %step)<nsw> + %start) LoopDispositions: { %loop: Computable }
145145
; CHECK-NEXT: %loop.iv.inc = add i32 %loop.iv, 1
146146
; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,129) S: [1,129) Exits: 128 LoopDispositions: { %loop: Computable }
147147
; CHECK-NEXT: Determining loop execution counts for: @f2
@@ -173,9 +173,9 @@ define void @f3(i1 %c) {
173173
; CHECK-LABEL: 'f3'
174174
; CHECK-NEXT: Classifying expressions for: @f3
175175
; CHECK-NEXT: %start = select i1 %c, i16 1000, i16 0
176-
; CHECK-NEXT: --> %start U: [0,1001) S: [-1024,1024)
176+
; CHECK-NEXT: --> %start U: [0,1001) S: [0,1001)
177177
; CHECK-NEXT: %step = select i1 %c, i16 1, i16 509
178-
; CHECK-NEXT: --> %step U: [1,510) S: [-512,512)
178+
; CHECK-NEXT: --> %step U: [1,510) S: [1,510)
179179
; CHECK-NEXT: %loop.iv = phi i16 [ 0, %entry ], [ %loop.iv.inc, %loop ]
180180
; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,128) S: [0,128) Exits: 127 LoopDispositions: { %loop: Computable }
181181
; CHECK-NEXT: %iv = phi i16 [ %start, %entry ], [ %iv.next, %loop ]
@@ -222,7 +222,7 @@ define void @f4(i1 %c) {
222222
; CHECK-LABEL: 'f4'
223223
; CHECK-NEXT: Classifying expressions for: @f4
224224
; CHECK-NEXT: %start = select i1 %c, i32 127, i32 0
225-
; CHECK-NEXT: --> %start U: [0,128) S: [-128,128)
225+
; CHECK-NEXT: --> %start U: [0,128) S: [0,128)
226226
; CHECK-NEXT: %step = select i1 %c, i32 -1, i32 1
227227
; CHECK-NEXT: --> %step U: [1,0) S: [-2,2)
228228
; CHECK-NEXT: %loop.iv = phi i32 [ 0, %entry ], [ %loop.iv.inc, %loop ]
@@ -232,7 +232,7 @@ define void @f4(i1 %c) {
232232
; CHECK-NEXT: %iv.trunc = trunc i32 %iv to i16
233233
; CHECK-NEXT: --> {(trunc i32 %start to i16),+,(trunc i32 %step to i16)}<%loop> U: full-set S: full-set Exits: ((trunc i32 %start to i16) + (127 * (trunc i32 %step to i16))<nsw>) LoopDispositions: { %loop: Computable }
234234
; CHECK-NEXT: %iv.next = add i32 %iv, %step
235-
; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: [-384,256) S: [-384,256) Exits: ((128 * %step)<nsw> + %start) LoopDispositions: { %loop: Computable }
235+
; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: [-256,256) S: [-256,256) Exits: ((128 * %step)<nsw> + %start) LoopDispositions: { %loop: Computable }
236236
; CHECK-NEXT: %loop.iv.inc = add i32 %loop.iv, 1
237237
; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,129) S: [1,129) Exits: 128 LoopDispositions: { %loop: Computable }
238238
; CHECK-NEXT: Determining loop execution counts for: @f4
@@ -270,7 +270,7 @@ define void @f5(i1 %c) {
270270
; CHECK-LABEL: 'f5'
271271
; CHECK-NEXT: Classifying expressions for: @f5
272272
; CHECK-NEXT: %start = select i1 %c, i32 127, i32 0
273-
; CHECK-NEXT: --> %start U: [0,128) S: [-128,128)
273+
; CHECK-NEXT: --> %start U: [0,128) S: [0,128)
274274
; CHECK-NEXT: %step = select i1 %c, i32 -1, i32 1
275275
; CHECK-NEXT: --> %step U: [1,0) S: [-2,2)
276276
; CHECK-NEXT: %loop.iv = phi i16 [ 0, %entry ], [ %loop.iv.inc, %loop ]
@@ -280,7 +280,7 @@ define void @f5(i1 %c) {
280280
; CHECK-NEXT: %iv.trunc = trunc i32 %iv to i16
281281
; CHECK-NEXT: --> {(trunc i32 %start to i16),+,(trunc i32 %step to i16)}<%loop> U: [0,128) S: [0,128) Exits: ((trunc i32 %start to i16) + (127 * (trunc i32 %step to i16))<nsw>) LoopDispositions: { %loop: Computable }
282282
; CHECK-NEXT: %iv.next = add i32 %iv, %step
283-
; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: [-384,256) S: [-384,256) Exits: ((128 * %step)<nsw> + %start) LoopDispositions: { %loop: Computable }
283+
; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: [-256,256) S: [-256,256) Exits: ((128 * %step)<nsw> + %start) LoopDispositions: { %loop: Computable }
284284
; CHECK-NEXT: %loop.iv.inc = add i16 %loop.iv, 1
285285
; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,129) S: [1,129) Exits: 128 LoopDispositions: { %loop: Computable }
286286
; CHECK-NEXT: Determining loop execution counts for: @f5
@@ -313,7 +313,7 @@ define void @f6(i1 %c) {
313313
; CHECK-LABEL: 'f6'
314314
; CHECK-NEXT: Classifying expressions for: @f6
315315
; CHECK-NEXT: %start = select i1 %c, i32 127, i32 0
316-
; CHECK-NEXT: --> %start U: [0,128) S: [-128,128)
316+
; CHECK-NEXT: --> %start U: [0,128) S: [0,128)
317317
; CHECK-NEXT: %step = select i1 %c, i32 -2, i32 0
318318
; CHECK-NEXT: --> %step U: [0,-1) S: [-2,2)
319319
; CHECK-NEXT: %loop.iv = phi i16 [ 0, %entry ], [ %loop.iv.inc, %loop ]
@@ -323,9 +323,9 @@ define void @f6(i1 %c) {
323323
; CHECK-NEXT: %step.plus.one = add i32 %step, 1
324324
; CHECK-NEXT: --> (1 + %step)<nuw><nsw> U: [1,0) S: [-1,3) Exits: (1 + %step)<nuw><nsw> LoopDispositions: { %loop: Invariant }
325325
; CHECK-NEXT: %iv.next = add i32 %iv, %step.plus.one
326-
; CHECK-NEXT: --> {(1 + %step + %start),+,(1 + %step)<nuw><nsw>}<%loop> U: [-256,384) S: [-256,384) Exits: (128 + (128 * %step)<nsw> + %start) LoopDispositions: { %loop: Computable }
326+
; CHECK-NEXT: --> {(1 + %step + %start),+,(1 + %step)<nuw><nsw>}<%loop> U: [-128,384) S: [-128,384) Exits: (128 + (128 * %step)<nsw> + %start) LoopDispositions: { %loop: Computable }
327327
; CHECK-NEXT: %iv.sext = sext i32 %iv to i64
328-
; CHECK-NEXT: --> {(sext i32 %start to i64),+,(1 + (sext i32 %step to i64))<nuw><nsw>}<nsw><%loop> U: [0,128) S: [0,128) Exits: (127 + (sext i32 %start to i64) + (127 * (sext i32 %step to i64))<nsw>) LoopDispositions: { %loop: Computable }
328+
; CHECK-NEXT: --> {(zext i32 %start to i64),+,(1 + (sext i32 %step to i64))<nuw><nsw>}<nsw><%loop> U: [0,128) S: [0,128) Exits: (127 + (zext i32 %start to i64) + (127 * (sext i32 %step to i64))<nsw>) LoopDispositions: { %loop: Computable }
329329
; CHECK-NEXT: %loop.iv.inc = add i16 %loop.iv, 1
330330
; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,129) S: [1,129) Exits: 128 LoopDispositions: { %loop: Computable }
331331
; CHECK-NEXT: Determining loop execution counts for: @f6
@@ -359,7 +359,7 @@ define void @f7(i1 %c) {
359359
; CHECK-LABEL: 'f7'
360360
; CHECK-NEXT: Classifying expressions for: @f7
361361
; CHECK-NEXT: %start = select i1 %c, i32 127, i32 0
362-
; CHECK-NEXT: --> %start U: [0,128) S: [-128,128)
362+
; CHECK-NEXT: --> %start U: [0,128) S: [0,128)
363363
; CHECK-NEXT: %step = select i1 %c, i32 -1, i32 1
364364
; CHECK-NEXT: --> %step U: [1,0) S: [-2,2)
365365
; CHECK-NEXT: %loop.iv = phi i16 [ 0, %entry ], [ %loop.iv.inc, %loop ]
@@ -369,7 +369,7 @@ define void @f7(i1 %c) {
369369
; CHECK-NEXT: %iv.trunc = trunc i32 %iv to i16
370370
; CHECK-NEXT: --> {(trunc i32 %start to i16),+,(trunc i32 %step to i16)}<%loop> U: [0,128) S: [0,128) Exits: ((trunc i32 %start to i16) + (127 * (trunc i32 %step to i16))<nsw>) LoopDispositions: { %loop: Computable }
371371
; CHECK-NEXT: %iv.next = add i32 %iv, %step
372-
; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: [-384,256) S: [-384,256) Exits: ((128 * %step)<nsw> + %start) LoopDispositions: { %loop: Computable }
372+
; CHECK-NEXT: --> {(%step + %start),+,%step}<%loop> U: [-256,256) S: [-256,256) Exits: ((128 * %step)<nsw> + %start) LoopDispositions: { %loop: Computable }
373373
; CHECK-NEXT: %iv.trunc.plus.one = add i16 %iv.trunc, 1
374374
; CHECK-NEXT: --> {(1 + (trunc i32 %start to i16))<nuw><nsw>,+,(trunc i32 %step to i16)}<%loop> U: [1,129) S: [1,129) Exits: (1 + (trunc i32 %start to i16) + (127 * (trunc i32 %step to i16))<nsw>) LoopDispositions: { %loop: Computable }
375375
; CHECK-NEXT: %iv.trunc.plus.two = add i16 %iv.trunc, 2

llvm/test/Analysis/ScalarEvolution/max-be-count-not-constant.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ define void @pluto(i32 %arg) {
1313
; CHECK-LABEL: 'pluto'
1414
; CHECK-NEXT: Classifying expressions for: @pluto
1515
; CHECK-NEXT: %tmp = ashr i32 %arg, 31
16-
; CHECK-NEXT: --> %tmp U: full-set S: [-1,1)
16+
; CHECK-NEXT: --> %tmp U: [-1,1) S: [-1,1)
1717
; CHECK-NEXT: %tmp1 = add nsw i32 %tmp, 2
18-
; CHECK-NEXT: --> (2 + %tmp)<nsw> U: [-2147483646,-2147483648) S: [1,3)
18+
; CHECK-NEXT: --> (2 + %tmp)<nsw> U: [1,3) S: [1,3)
1919
; CHECK-NEXT: %tmp3 = phi i32 [ 0, %bb ], [ %tmp4, %bb2 ]
20-
; CHECK-NEXT: --> {0,+,(2 + %tmp)<nsw>}<nuw><nsw><%bb2> U: [0,5) S: [0,5) Exits: ((2 + %tmp)<nsw> * (1 /u (2 + %tmp)<nsw>)) LoopDispositions: { %bb2: Computable }
20+
; CHECK-NEXT: --> {0,+,(2 + %tmp)<nsw>}<nuw><nsw><%bb2> U: [0,3) S: [0,3) Exits: ((2 + %tmp)<nsw> * (1 /u (2 + %tmp)<nsw>)) LoopDispositions: { %bb2: Computable }
2121
; CHECK-NEXT: %tmp4 = add nuw nsw i32 %tmp1, %tmp3
22-
; CHECK-NEXT: --> {(2 + %tmp)<nsw>,+,(2 + %tmp)<nsw>}<nuw><nsw><%bb2> U: [1,7) S: [1,7) Exits: (2 + ((2 + %tmp)<nsw> * (1 /u (2 + %tmp)<nsw>)) + %tmp) LoopDispositions: { %bb2: Computable }
22+
; CHECK-NEXT: --> {(2 + %tmp)<nsw>,+,(2 + %tmp)<nsw>}<nuw><nsw><%bb2> U: [1,5) S: [1,5) Exits: (2 + ((2 + %tmp)<nsw> * (1 /u (2 + %tmp)<nsw>)) + %tmp) LoopDispositions: { %bb2: Computable }
2323
; CHECK-NEXT: Determining loop execution counts for: @pluto
2424
; CHECK-NEXT: Loop %bb2: backedge-taken count is (1 /u (2 + %tmp)<nsw>)
25-
; CHECK-NEXT: Loop %bb2: max backedge-taken count is 2
25+
; CHECK-NEXT: Loop %bb2: max backedge-taken count is 1
2626
; CHECK-NEXT: Loop %bb2: Predicated backedge-taken count is (1 /u (2 + %tmp)<nsw>)
2727
; CHECK-NEXT: Predicates:
2828
; CHECK: Loop %bb2: Trip multiple is 1

0 commit comments

Comments
 (0)