Skip to content

Commit 7078504

Browse files
committed
[indvars] Prove non-negative for widening IVs in count down loops
If we have a count down loop with an unsigned backedge test, SCEV is currently failing to prove that the IV is non-negative. The observation we can use is that if the increment of a loop would have been a NUW subtract (i.e. not cross zero), then an IV which starts with a positive value must be positive on all iterations. We can re-infer the sub nuw fact from an add with negative offset by checking to see if the loop backedge is guarded by a condition which implies IV >=u abs(step). I took several attempts at fixing this in SCEV itself, but decided for the moment, having indvars do the expensive proof is a better tradeoff. Once this is in, I plan to investigate SCEV further. I think we probably can sink this into SCEV, I just haven't quite found the right place yet.
1 parent 7c93452 commit 7078504

File tree

3 files changed

+64
-35
lines changed

3 files changed

+64
-35
lines changed

llvm/lib/Transforms/Utils/SimplifyIndVar.cpp

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,7 @@ class WidenIV {
11221122
bool widenLoopCompare(NarrowIVDefUse DU);
11231123
bool widenWithVariantUse(NarrowIVDefUse DU);
11241124

1125+
bool isKnownNonNegative(const SCEV *S);
11251126
void pushNarrowIVUsers(Instruction *NarrowDef, Instruction *WideDef);
11261127

11271128
private:
@@ -1885,12 +1886,45 @@ Instruction *WidenIV::widenIVUse(WidenIV::NarrowIVDefUse DU, SCEVExpander &Rewri
18851886
return WideUse;
18861887
}
18871888

1889+
// A special version of isKnownNonNegative which additionally tries
1890+
// to prove that an addrec with a negative step would be non-negative
1891+
// because the start is non-negative, and the increment would have
1892+
// "nuw" if using a sub-instruction.
1893+
// TODO: All of this should be sunk into SCEV once we figure out how to
1894+
// reasonable do so without exploding compile time.
1895+
bool WidenIV::isKnownNonNegative(const SCEV *S) {
1896+
const SCEV *Zero = SE->getZero(S->getType());
1897+
if (SE->isKnownPredicate(ICmpInst::ICMP_SGE, S, Zero))
1898+
return true;
1899+
auto *AR = dyn_cast<SCEVAddRecExpr>(S);
1900+
if (!AR || !AR->isAffine())
1901+
return false;
1902+
1903+
const SCEV *Start = AR->getStart();
1904+
const SCEV *Step = AR->getStepRecurrence(*SE);
1905+
const SCEV *PostInc = AR->getPostIncExpr(*SE);
1906+
// For a negative step, we can prove the result non-negative if the addrec
1907+
// only traverses values in the range zext([0,UINT_MAX]).
1908+
// TODO: Consider extending this for unknown steps? Would need to
1909+
// handle the positive step bound
1910+
if (!SE->isKnownNegative(Step))
1911+
return false;
1912+
if (!SE->isLoopEntryGuardedByCond(L, ICmpInst::ICMP_SGE, Start, Zero))
1913+
return false;
1914+
1915+
// Check for the unsigned form of these comparisons. The signed form
1916+
// should have been handled recursively in the query above.
1917+
uint32_t BitWidth = cast<IntegerType>(AR->getType())->getBitWidth();
1918+
const SCEV *N = SE->getConstant(APInt::getMaxValue(BitWidth) -
1919+
SE->getSignedRangeMin(Step));
1920+
return SE->isLoopBackedgeGuardedByCond(L, ICmpInst::ICMP_UGT, AR, N) ||
1921+
SE->isLoopBackedgeGuardedByCond(L, ICmpInst::ICMP_UGT, PostInc, N);
1922+
}
1923+
18881924
/// Add eligible users of NarrowDef to NarrowIVUsers.
18891925
void WidenIV::pushNarrowIVUsers(Instruction *NarrowDef, Instruction *WideDef) {
1890-
const SCEV *NarrowSCEV = SE->getSCEV(NarrowDef);
1891-
bool NonNegativeDef =
1892-
SE->isKnownPredicate(ICmpInst::ICMP_SGE, NarrowSCEV,
1893-
SE->getZero(NarrowSCEV->getType()));
1926+
assert(L->contains(NarrowDef));
1927+
const bool NonNegativeDef = isKnownNonNegative(SE->getSCEV(NarrowDef));
18941928
for (User *U : NarrowDef->users()) {
18951929
Instruction *NarrowUser = cast<Instruction>(U);
18961930

llvm/test/Transforms/IndVarSimplify/AArch64/widen-loop-comp.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -507,15 +507,15 @@ declare void @consume.i1(i1)
507507
define i32 @test10(i32 %v) {
508508
; CHECK-LABEL: @test10(
509509
; CHECK-NEXT: entry:
510-
; CHECK-NEXT: [[SEXT:%.*]] = sext i32 [[V:%.*]] to i64
510+
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[V:%.*]] to i64
511511
; CHECK-NEXT: br label [[LOOP:%.*]]
512512
; CHECK: loop:
513513
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ], [ 0, [[ENTRY:%.*]] ]
514514
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
515-
; CHECK-NEXT: [[TMP0:%.*]] = mul nsw i64 [[INDVARS_IV]], -1
516-
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[TMP0]], [[SEXT]]
517-
; CHECK-NEXT: call void @consume.i1(i1 [[TMP1]])
518-
; CHECK-NEXT: call void @consume.i64(i64 [[TMP0]])
515+
; CHECK-NEXT: [[TMP1:%.*]] = mul nsw i64 [[INDVARS_IV]], -1
516+
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[TMP1]], [[TMP0]]
517+
; CHECK-NEXT: call void @consume.i1(i1 [[CMP]])
518+
; CHECK-NEXT: call void @consume.i64(i64 [[TMP1]])
519519
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], 11
520520
; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[LEAVE:%.*]]
521521
; CHECK: leave:

llvm/test/Transforms/IndVarSimplify/widen-nonnegative-countdown.ll

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,10 @@ define void @zext_postinc(ptr %A, i32 %start) {
8282
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
8383
; CHECK: for.body:
8484
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[TMP0]], [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
85-
; CHECK-NEXT: [[J_016_US:%.*]] = phi i32 [ [[INC_US:%.*]], [[FOR_BODY]] ], [ [[START]], [[FOR_BODY_PREHEADER]] ]
8685
; CHECK-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[INDVARS_IV]]
8786
; CHECK-NEXT: tail call void @use_ptr(ptr [[ARRAYIDX_US]])
88-
; CHECK-NEXT: [[INC_US]] = add nsw i32 [[J_016_US]], -1
89-
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i32 [[INC_US]], 6
9087
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
88+
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i64 [[INDVARS_IV_NEXT]], 6
9189
; CHECK-NEXT: br i1 [[CMP2_US]], label [[FOR_BODY]], label [[EXIT_LOOPEXIT:%.*]]
9290
; CHECK: exit.loopexit:
9391
; CHECK-NEXT: br label [[EXIT]]
@@ -124,8 +122,8 @@ define void @zext_preinc(ptr %A, i32 %start) {
124122
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[TMP0]], [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
125123
; CHECK-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[INDVARS_IV]]
126124
; CHECK-NEXT: tail call void @use_ptr(ptr [[ARRAYIDX_US]])
127-
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i64 [[INDVARS_IV]], 6
128125
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
126+
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i64 [[INDVARS_IV]], 6
129127
; CHECK-NEXT: br i1 [[CMP2_US]], label [[FOR_BODY]], label [[EXIT_LOOPEXIT:%.*]]
130128
; CHECK: exit.loopexit:
131129
; CHECK-NEXT: br label [[EXIT]]
@@ -223,8 +221,7 @@ define void @sext_postinc(ptr %A, i32 %start) {
223221
; CHECK-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[INDVARS_IV]]
224222
; CHECK-NEXT: tail call void @use_ptr(ptr [[ARRAYIDX_US]])
225223
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
226-
; CHECK-NEXT: [[TMP1:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
227-
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i32 [[TMP1]], 6
224+
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i64 [[INDVARS_IV_NEXT]], 6
228225
; CHECK-NEXT: br i1 [[CMP2_US]], label [[FOR_BODY]], label [[EXIT_LOOPEXIT:%.*]]
229226
; CHECK: exit.loopexit:
230227
; CHECK-NEXT: br label [[EXIT]]
@@ -262,8 +259,7 @@ define void @sext_preinc(ptr %A, i32 %start) {
262259
; CHECK-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[INDVARS_IV]]
263260
; CHECK-NEXT: tail call void @use_ptr(ptr [[ARRAYIDX_US]])
264261
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
265-
; CHECK-NEXT: [[TMP1:%.*]] = trunc i64 [[INDVARS_IV]] to i32
266-
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i32 [[TMP1]], 6
262+
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i64 [[INDVARS_IV]], 6
267263
; CHECK-NEXT: br i1 [[CMP2_US]], label [[FOR_BODY]], label [[EXIT_LOOPEXIT:%.*]]
268264
; CHECK: exit.loopexit:
269265
; CHECK-NEXT: br label [[EXIT]]
@@ -365,15 +361,13 @@ define void @zext_postinc_offset_constant_one(ptr %A, i32 %start) {
365361
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
366362
; CHECK: for.body:
367363
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[TMP0]], [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
368-
; CHECK-NEXT: [[J_016_US:%.*]] = phi i32 [ [[INC_US:%.*]], [[FOR_BODY]] ], [ [[START]], [[FOR_BODY_PREHEADER]] ]
369364
; CHECK-NEXT: [[TMP1:%.*]] = trunc i64 [[INDVARS_IV]] to i32
370365
; CHECK-NEXT: [[ADD_US:%.*]] = add i32 [[TMP1]], 1
371366
; CHECK-NEXT: [[IDXPROM_US:%.*]] = zext i32 [[ADD_US]] to i64
372367
; CHECK-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[IDXPROM_US]]
373368
; CHECK-NEXT: tail call void @use_ptr(ptr [[ARRAYIDX_US]])
374-
; CHECK-NEXT: [[INC_US]] = add nsw i32 [[J_016_US]], -1
375-
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i32 [[INC_US]], 6
376369
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
370+
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i64 [[INDVARS_IV_NEXT]], 6
377371
; CHECK-NEXT: br i1 [[CMP2_US]], label [[FOR_BODY]], label [[EXIT_LOOPEXIT:%.*]]
378372
; CHECK: exit.loopexit:
379373
; CHECK-NEXT: br label [[EXIT]]
@@ -414,8 +408,8 @@ define void @zext_preinc_offset_constant_one(ptr %A, i32 %start) {
414408
; CHECK-NEXT: [[IDXPROM_US:%.*]] = zext i32 [[ADD_US]] to i64
415409
; CHECK-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[IDXPROM_US]]
416410
; CHECK-NEXT: tail call void @use_ptr(ptr [[ARRAYIDX_US]])
417-
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i64 [[INDVARS_IV]], 6
418411
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
412+
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i64 [[INDVARS_IV]], 6
419413
; CHECK-NEXT: br i1 [[CMP2_US]], label [[FOR_BODY]], label [[EXIT_LOOPEXIT:%.*]]
420414
; CHECK: exit.loopexit:
421415
; CHECK-NEXT: br label [[EXIT]]
@@ -521,8 +515,7 @@ define void @sext_postinc_offset_constant_one(ptr %A, i32 %start) {
521515
; CHECK-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[IDXPROM_US]]
522516
; CHECK-NEXT: tail call void @use_ptr(ptr [[ARRAYIDX_US]])
523517
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
524-
; CHECK-NEXT: [[TMP2:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
525-
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i32 [[TMP2]], 6
518+
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i64 [[INDVARS_IV_NEXT]], 6
526519
; CHECK-NEXT: br i1 [[CMP2_US]], label [[FOR_BODY]], label [[EXIT_LOOPEXIT:%.*]]
527520
; CHECK: exit.loopexit:
528521
; CHECK-NEXT: br label [[EXIT]]
@@ -564,8 +557,7 @@ define void @sext_preinc_offset_constant_one(ptr %A, i32 %start) {
564557
; CHECK-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[IDXPROM_US]]
565558
; CHECK-NEXT: tail call void @use_ptr(ptr [[ARRAYIDX_US]])
566559
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
567-
; CHECK-NEXT: [[TMP2:%.*]] = trunc i64 [[INDVARS_IV]] to i32
568-
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i32 [[TMP2]], 6
560+
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i64 [[INDVARS_IV]], 6
569561
; CHECK-NEXT: br i1 [[CMP2_US]], label [[FOR_BODY]], label [[EXIT_LOOPEXIT:%.*]]
570562
; CHECK: exit.loopexit:
571563
; CHECK-NEXT: br label [[EXIT]]
@@ -662,15 +654,18 @@ define void @zext_postinc_offset_constant_minus_one(ptr %A, i32 %start) {
662654
; CHECK-NEXT: [[NONPOS:%.*]] = icmp slt i32 [[START:%.*]], 2
663655
; CHECK-NEXT: br i1 [[NONPOS]], label [[EXIT:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
664656
; CHECK: for.body.preheader:
657+
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[START]] to i64
665658
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
666659
; CHECK: for.body:
660+
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[TMP0]], [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
667661
; CHECK-NEXT: [[J_016_US:%.*]] = phi i32 [ [[INC_US:%.*]], [[FOR_BODY]] ], [ [[START]], [[FOR_BODY_PREHEADER]] ]
668662
; CHECK-NEXT: [[ADD_US:%.*]] = add i32 [[J_016_US]], -1
669663
; CHECK-NEXT: [[IDXPROM_US:%.*]] = zext i32 [[ADD_US]] to i64
670664
; CHECK-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[IDXPROM_US]]
671665
; CHECK-NEXT: tail call void @use_ptr(ptr [[ARRAYIDX_US]])
666+
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
672667
; CHECK-NEXT: [[INC_US]] = add nsw i32 [[J_016_US]], -1
673-
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i32 [[INC_US]], 6
668+
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i64 [[INDVARS_IV_NEXT]], 6
674669
; CHECK-NEXT: br i1 [[CMP2_US]], label [[FOR_BODY]], label [[EXIT_LOOPEXIT:%.*]]
675670
; CHECK: exit.loopexit:
676671
; CHECK-NEXT: br label [[EXIT]]
@@ -711,9 +706,9 @@ define void @zext_preinc_offset_constant_minus_one(ptr %A, i32 %start) {
711706
; CHECK-NEXT: [[IDXPROM_US:%.*]] = zext i32 [[ADD_US]] to i64
712707
; CHECK-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[IDXPROM_US]]
713708
; CHECK-NEXT: tail call void @use_ptr(ptr [[ARRAYIDX_US]])
709+
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
714710
; CHECK-NEXT: [[INC_US]] = add nsw i32 [[J_016_US]], -1
715711
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i64 [[INDVARS_IV]], 6
716-
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
717712
; CHECK-NEXT: br i1 [[CMP2_US]], label [[FOR_BODY]], label [[EXIT_LOOPEXIT:%.*]]
718713
; CHECK: exit.loopexit:
719714
; CHECK-NEXT: br label [[EXIT]]
@@ -811,14 +806,14 @@ define void @sext_postinc_offset_constant_minus_one(ptr %A, i32 %start) {
811806
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
812807
; CHECK: for.body:
813808
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[TMP0]], [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
814-
; CHECK-NEXT: [[TMP1:%.*]] = trunc i64 [[INDVARS_IV]] to i32
815-
; CHECK-NEXT: [[ADD_US:%.*]] = add i32 [[TMP1]], -1
809+
; CHECK-NEXT: [[J_016_US:%.*]] = phi i32 [ [[INC_US:%.*]], [[FOR_BODY]] ], [ [[START]], [[FOR_BODY_PREHEADER]] ]
810+
; CHECK-NEXT: [[ADD_US:%.*]] = add i32 [[J_016_US]], -1
816811
; CHECK-NEXT: [[IDXPROM_US:%.*]] = sext i32 [[ADD_US]] to i64
817812
; CHECK-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[IDXPROM_US]]
818813
; CHECK-NEXT: tail call void @use_ptr(ptr [[ARRAYIDX_US]])
819814
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
820-
; CHECK-NEXT: [[TMP2:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
821-
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i32 [[TMP2]], 6
815+
; CHECK-NEXT: [[INC_US]] = add nsw i32 [[J_016_US]], -1
816+
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i64 [[INDVARS_IV_NEXT]], 6
822817
; CHECK-NEXT: br i1 [[CMP2_US]], label [[FOR_BODY]], label [[EXIT_LOOPEXIT:%.*]]
823818
; CHECK: exit.loopexit:
824819
; CHECK-NEXT: br label [[EXIT]]
@@ -854,14 +849,14 @@ define void @sext_preinc_offset_constant_minus_one(ptr %A, i32 %start) {
854849
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
855850
; CHECK: for.body:
856851
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[TMP0]], [[FOR_BODY_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
857-
; CHECK-NEXT: [[TMP1:%.*]] = trunc i64 [[INDVARS_IV]] to i32
858-
; CHECK-NEXT: [[ADD_US:%.*]] = add i32 [[TMP1]], -1
852+
; CHECK-NEXT: [[J_016_US:%.*]] = phi i32 [ [[INC_US:%.*]], [[FOR_BODY]] ], [ [[START]], [[FOR_BODY_PREHEADER]] ]
853+
; CHECK-NEXT: [[ADD_US:%.*]] = add i32 [[J_016_US]], -1
859854
; CHECK-NEXT: [[IDXPROM_US:%.*]] = sext i32 [[ADD_US]] to i64
860855
; CHECK-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[IDXPROM_US]]
861856
; CHECK-NEXT: tail call void @use_ptr(ptr [[ARRAYIDX_US]])
862857
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1
863-
; CHECK-NEXT: [[TMP2:%.*]] = trunc i64 [[INDVARS_IV]] to i32
864-
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i32 [[TMP2]], 6
858+
; CHECK-NEXT: [[INC_US]] = add nsw i32 [[J_016_US]], -1
859+
; CHECK-NEXT: [[CMP2_US:%.*]] = icmp ugt i64 [[INDVARS_IV]], 6
865860
; CHECK-NEXT: br i1 [[CMP2_US]], label [[FOR_BODY]], label [[EXIT_LOOPEXIT:%.*]]
866861
; CHECK: exit.loopexit:
867862
; CHECK-NEXT: br label [[EXIT]]

0 commit comments

Comments
 (0)