Skip to content

Commit c6b13a2

Browse files
authored
Revert "SCEV: teach isImpliedViaOperations about samesign" (llvm#126506)
The commit f5d24e6 is buggy, and following miscompiles have been reported: llvm#126409 and llvm#124270 (comment) Revert it while we investigate.
1 parent af2a228 commit c6b13a2

File tree

4 files changed

+59
-166
lines changed

4 files changed

+59
-166
lines changed

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11860,13 +11860,15 @@ bool ScalarEvolution::isImpliedCondBalancedTypes(
1186011860
}
1186111861

1186211862
// Check whether the found predicate is the same as the desired predicate.
11863-
if (auto P = CmpPredicate::getMatching(FoundPred, Pred))
11864-
return isImpliedCondOperands(*P, LHS, RHS, FoundLHS, FoundRHS, CtxI);
11863+
// FIXME: use CmpPredicate::getMatching here.
11864+
if (FoundPred == static_cast<CmpInst::Predicate>(Pred))
11865+
return isImpliedCondOperands(Pred, LHS, RHS, FoundLHS, FoundRHS, CtxI);
1186511866

1186611867
// Check whether swapping the found predicate makes it the same as the
1186711868
// desired predicate.
11868-
if (auto P = CmpPredicate::getMatching(
11869-
ICmpInst::getSwappedCmpPredicate(FoundPred), Pred)) {
11869+
// FIXME: use CmpPredicate::getMatching here.
11870+
if (ICmpInst::getSwappedCmpPredicate(FoundPred) ==
11871+
static_cast<CmpInst::Predicate>(Pred)) {
1187011872
// We can write the implication
1187111873
// 0. LHS Pred RHS <- FoundLHS SwapPred FoundRHS
1187211874
// using one of the following ways:
@@ -11877,23 +11879,22 @@ bool ScalarEvolution::isImpliedCondBalancedTypes(
1187711879
// Forms 1. and 2. require swapping the operands of one condition. Don't
1187811880
// do this if it would break canonical constant/addrec ordering.
1187911881
if (!isa<SCEVConstant>(RHS) && !isa<SCEVAddRecExpr>(LHS))
11880-
return isImpliedCondOperands(ICmpInst::getSwappedCmpPredicate(*P), RHS,
11881-
LHS, FoundLHS, FoundRHS, CtxI);
11882+
return isImpliedCondOperands(FoundPred, RHS, LHS, FoundLHS, FoundRHS,
11883+
CtxI);
1188211884
if (!isa<SCEVConstant>(FoundRHS) && !isa<SCEVAddRecExpr>(FoundLHS))
11883-
return isImpliedCondOperands(*P, LHS, RHS, FoundRHS, FoundLHS, CtxI);
11885+
return isImpliedCondOperands(Pred, LHS, RHS, FoundRHS, FoundLHS, CtxI);
1188411886

1188511887
// There's no clear preference between forms 3. and 4., try both. Avoid
1188611888
// forming getNotSCEV of pointer values as the resulting subtract is
1188711889
// not legal.
1188811890
if (!LHS->getType()->isPointerTy() && !RHS->getType()->isPointerTy() &&
11889-
isImpliedCondOperands(ICmpInst::getSwappedCmpPredicate(*P),
11890-
getNotSCEV(LHS), getNotSCEV(RHS), FoundLHS,
11891-
FoundRHS, CtxI))
11891+
isImpliedCondOperands(FoundPred, getNotSCEV(LHS), getNotSCEV(RHS),
11892+
FoundLHS, FoundRHS, CtxI))
1189211893
return true;
1189311894

1189411895
if (!FoundLHS->getType()->isPointerTy() &&
1189511896
!FoundRHS->getType()->isPointerTy() &&
11896-
isImpliedCondOperands(*P, LHS, RHS, getNotSCEV(FoundLHS),
11897+
isImpliedCondOperands(Pred, LHS, RHS, getNotSCEV(FoundLHS),
1189711898
getNotSCEV(FoundRHS), CtxI))
1189811899
return true;
1189911900

@@ -12569,16 +12570,14 @@ bool ScalarEvolution::isImpliedViaOperations(CmpPredicate Pred, const SCEV *LHS,
1256912570
return false;
1257012571

1257112572
// We only want to work with GT comparison so far.
12572-
if (ICmpInst::isLT(Pred)) {
12573+
if (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_SLT) {
1257312574
Pred = ICmpInst::getSwappedCmpPredicate(Pred);
1257412575
std::swap(LHS, RHS);
1257512576
std::swap(FoundLHS, FoundRHS);
1257612577
}
1257712578

12578-
CmpInst::Predicate P = Pred.getPreferredSignedPredicate();
12579-
1258012579
// For unsigned, try to reduce it to corresponding signed comparison.
12581-
if (P == ICmpInst::ICMP_UGT)
12580+
if (Pred == ICmpInst::ICMP_UGT)
1258212581
// We can replace unsigned predicate with its signed counterpart if all
1258312582
// involved values are non-negative.
1258412583
// TODO: We could have better support for unsigned.
@@ -12591,10 +12590,10 @@ bool ScalarEvolution::isImpliedViaOperations(CmpPredicate Pred, const SCEV *LHS,
1259112590
FoundRHS) &&
1259212591
isImpliedCondOperands(ICmpInst::ICMP_SGT, RHS, MinusOne, FoundLHS,
1259312592
FoundRHS))
12594-
P = ICmpInst::ICMP_SGT;
12593+
Pred = ICmpInst::ICMP_SGT;
1259512594
}
1259612595

12597-
if (P != ICmpInst::ICMP_SGT)
12596+
if (Pred != ICmpInst::ICMP_SGT)
1259812597
return false;
1259912598

1260012599
auto GetOpFromSExt = [&](const SCEV *S) {

llvm/test/Analysis/ScalarEvolution/exit-count-samesign.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
define i32 @exit_count_samesign(i32 %iter.count, ptr %ptr) {
66
; CHECK-LABEL: 'exit_count_samesign'
77
; CHECK-NEXT: Determining loop execution counts for: @exit_count_samesign
8-
; CHECK-NEXT: Loop %inner.loop: backedge-taken count is {(-2 + %iter.count),+,-1}<nw><%outer.loop>
8+
; CHECK-NEXT: Loop %inner.loop: backedge-taken count is (-1 + (1 smax {(-1 + %iter.count)<nsw>,+,-1}<nsw><%outer.loop>))<nsw>
99
; CHECK-NEXT: Loop %inner.loop: constant max backedge-taken count is i32 2147483646
10-
; CHECK-NEXT: Loop %inner.loop: symbolic max backedge-taken count is {(-2 + %iter.count),+,-1}<nw><%outer.loop>
10+
; CHECK-NEXT: Loop %inner.loop: symbolic max backedge-taken count is (-1 + (1 smax {(-1 + %iter.count)<nsw>,+,-1}<nsw><%outer.loop>))<nsw>
1111
; CHECK-NEXT: Loop %inner.loop: Trip multiple is 1
1212
; CHECK-NEXT: Loop %outer.loop: <multiple exits> Unpredictable backedge-taken count.
1313
; CHECK-NEXT: Loop %outer.loop: Unpredictable constant max backedge-taken count.

llvm/test/Analysis/ScalarEvolution/implied-via-division.ll

Lines changed: 33 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
; RUN: opt < %s -disable-output -passes="print<scalar-evolution>" \
33
; RUN: -scalar-evolution-classify-expressions=0 2>&1 | FileCheck %s
44

5-
define void @implied1(i32 %n) {
6-
; Prove that (n s> 1) ===> (n / 2 s> 0).
7-
; CHECK-LABEL: 'implied1'
8-
; CHECK-NEXT: Determining loop execution counts for: @implied1
5+
declare void @llvm.experimental.guard(i1, ...)
6+
7+
define void @test_1(i32 %n) nounwind {
8+
; Prove that (n > 1) ===> (n / 2 > 0).
9+
; CHECK-LABEL: 'test_1'
10+
; CHECK-NEXT: Determining loop execution counts for: @test_1
911
; CHECK-NEXT: Loop %header: backedge-taken count is (-1 + %n.div.2)<nsw>
1012
; CHECK-NEXT: Loop %header: constant max backedge-taken count is i32 1073741822
1113
; CHECK-NEXT: Loop %header: symbolic max backedge-taken count is (-1 + %n.div.2)<nsw>
@@ -27,35 +29,10 @@ exit:
2729
ret void
2830
}
2931

30-
define void @implied1_samesign(i32 %n) {
31-
; Prove that (n > 1) ===> (n / 2 s> 0).
32-
; CHECK-LABEL: 'implied1_samesign'
33-
; CHECK-NEXT: Determining loop execution counts for: @implied1_samesign
34-
; CHECK-NEXT: Loop %header: backedge-taken count is (-1 + %n.div.2)<nsw>
35-
; CHECK-NEXT: Loop %header: constant max backedge-taken count is i32 1073741822
36-
; CHECK-NEXT: Loop %header: symbolic max backedge-taken count is (-1 + %n.div.2)<nsw>
37-
; CHECK-NEXT: Loop %header: Trip multiple is 1
38-
;
39-
entry:
40-
%cmp1 = icmp samesign ugt i32 %n, 1
41-
%n.div.2 = sdiv i32 %n, 2
42-
call void @llvm.assume(i1 %cmp1)
43-
br label %header
44-
45-
header:
46-
%indvar = phi i32 [ %indvar.next, %header ], [ 0, %entry ]
47-
%indvar.next = add i32 %indvar, 1
48-
%exitcond = icmp sgt i32 %n.div.2, %indvar.next
49-
br i1 %exitcond, label %header, label %exit
50-
51-
exit:
52-
ret void
53-
}
54-
55-
define void @implied1_neg(i32 %n) {
56-
; Prove that (n s> 0) =\=> (n / 2 s> 0).
57-
; CHECK-LABEL: 'implied1_neg'
58-
; CHECK-NEXT: Determining loop execution counts for: @implied1_neg
32+
define void @test_1neg(i32 %n) nounwind {
33+
; Prove that (n > 0) =\=> (n / 2 > 0).
34+
; CHECK-LABEL: 'test_1neg'
35+
; CHECK-NEXT: Determining loop execution counts for: @test_1neg
5936
; CHECK-NEXT: Loop %header: backedge-taken count is (-1 + (1 smax %n.div.2))<nsw>
6037
; CHECK-NEXT: Loop %header: constant max backedge-taken count is i32 1073741822
6138
; CHECK-NEXT: Loop %header: symbolic max backedge-taken count is (-1 + (1 smax %n.div.2))<nsw>
@@ -77,10 +54,10 @@ exit:
7754
ret void
7855
}
7956

80-
define void @implied2(i32 %n) {
81-
; Prove that (n s>= 2) ===> (n / 2 s> 0).
82-
; CHECK-LABEL: 'implied2'
83-
; CHECK-NEXT: Determining loop execution counts for: @implied2
57+
define void @test_2(i32 %n) nounwind {
58+
; Prove that (n >= 2) ===> (n / 2 > 0).
59+
; CHECK-LABEL: 'test_2'
60+
; CHECK-NEXT: Determining loop execution counts for: @test_2
8461
; CHECK-NEXT: Loop %header: backedge-taken count is (-1 + %n.div.2)<nsw>
8562
; CHECK-NEXT: Loop %header: constant max backedge-taken count is i32 1073741822
8663
; CHECK-NEXT: Loop %header: symbolic max backedge-taken count is (-1 + %n.div.2)<nsw>
@@ -102,35 +79,10 @@ exit:
10279
ret void
10380
}
10481

105-
define void @implied2_samesign(i32 %n) {
106-
; Prove that (n >= 2) ===> (n / 2 s> 0).
107-
; CHECK-LABEL: 'implied2_samesign'
108-
; CHECK-NEXT: Determining loop execution counts for: @implied2_samesign
109-
; CHECK-NEXT: Loop %header: backedge-taken count is (-1 + (1 smax %n.div.2))<nsw>
110-
; CHECK-NEXT: Loop %header: constant max backedge-taken count is i32 1073741822
111-
; CHECK-NEXT: Loop %header: symbolic max backedge-taken count is (-1 + (1 smax %n.div.2))<nsw>
112-
; CHECK-NEXT: Loop %header: Trip multiple is 1
113-
;
114-
entry:
115-
%cmp1 = icmp samesign uge i32 %n, 2
116-
%n.div.2 = sdiv i32 %n, 2
117-
call void @llvm.assume(i1 %cmp1)
118-
br label %header
119-
120-
header:
121-
%indvar = phi i32 [ %indvar.next, %header ], [ 0, %entry ]
122-
%indvar.next = add i32 %indvar, 1
123-
%exitcond = icmp sgt i32 %n.div.2, %indvar.next
124-
br i1 %exitcond, label %header, label %exit
125-
126-
exit:
127-
ret void
128-
}
129-
130-
define void @implied2_neg(i32 %n) {
131-
; Prove that (n s>= 1) =\=> (n / 2 s> 0).
132-
; CHECK-LABEL: 'implied2_neg'
133-
; CHECK-NEXT: Determining loop execution counts for: @implied2_neg
82+
define void @test_2neg(i32 %n) nounwind {
83+
; Prove that (n >= 1) =\=> (n / 2 > 0).
84+
; CHECK-LABEL: 'test_2neg'
85+
; CHECK-NEXT: Determining loop execution counts for: @test_2neg
13486
; CHECK-NEXT: Loop %header: backedge-taken count is (-1 + (1 smax %n.div.2))<nsw>
13587
; CHECK-NEXT: Loop %header: constant max backedge-taken count is i32 1073741822
13688
; CHECK-NEXT: Loop %header: symbolic max backedge-taken count is (-1 + (1 smax %n.div.2))<nsw>
@@ -152,10 +104,10 @@ exit:
152104
ret void
153105
}
154106

155-
define void @implied3(i32 %n) {
156-
; Prove that (n s> -2) ===> (n / 2 s>= 0).
157-
; CHECK-LABEL: 'implied3'
158-
; CHECK-NEXT: Determining loop execution counts for: @implied3
107+
define void @test_3(i32 %n) nounwind {
108+
; Prove that (n > -2) ===> (n / 2 >= 0).
109+
; CHECK-LABEL: 'test_3'
110+
; CHECK-NEXT: Determining loop execution counts for: @test_3
159111
; CHECK-NEXT: Loop %header: backedge-taken count is (1 + %n.div.2)<nsw>
160112
; CHECK-NEXT: Loop %header: constant max backedge-taken count is i32 1073741824
161113
; CHECK-NEXT: Loop %header: symbolic max backedge-taken count is (1 + %n.div.2)<nsw>
@@ -177,35 +129,10 @@ exit:
177129
ret void
178130
}
179131

180-
define void @implied3_samesign(i32 %n) {
181-
; Prove that (n > -2) ===> (n / 2 s>= 0).
182-
; CHECK-LABEL: 'implied3_samesign'
183-
; CHECK-NEXT: Determining loop execution counts for: @implied3_samesign
184-
; CHECK-NEXT: Loop %header: backedge-taken count is (1 + %n.div.2)<nsw>
185-
; CHECK-NEXT: Loop %header: constant max backedge-taken count is i32 1
186-
; CHECK-NEXT: Loop %header: symbolic max backedge-taken count is (1 + %n.div.2)<nsw>
187-
; CHECK-NEXT: Loop %header: Trip multiple is 1
188-
;
189-
entry:
190-
%cmp1 = icmp samesign ugt i32 %n, -2
191-
%n.div.2 = sdiv i32 %n, 2
192-
call void @llvm.assume(i1 %cmp1)
193-
br label %header
194-
195-
header:
196-
%indvar = phi i32 [ %indvar.next, %header ], [ 0, %entry ]
197-
%indvar.next = add i32 %indvar, 1
198-
%exitcond = icmp sge i32 %n.div.2, %indvar
199-
br i1 %exitcond, label %header, label %exit
200-
201-
exit:
202-
ret void
203-
}
204-
205-
define void @implied3_neg(i32 %n) {
132+
define void @test_3neg(i32 %n) nounwind {
206133
; Prove that (n > -3) =\=> (n / 2 >= 0).
207-
; CHECK-LABEL: 'implied3_neg'
208-
; CHECK-NEXT: Determining loop execution counts for: @implied3_neg
134+
; CHECK-LABEL: 'test_3neg'
135+
; CHECK-NEXT: Determining loop execution counts for: @test_3neg
209136
; CHECK-NEXT: Loop %header: backedge-taken count is (0 smax (1 + %n.div.2)<nsw>)
210137
; CHECK-NEXT: Loop %header: constant max backedge-taken count is i32 1073741824
211138
; CHECK-NEXT: Loop %header: symbolic max backedge-taken count is (0 smax (1 + %n.div.2)<nsw>)
@@ -227,10 +154,10 @@ exit:
227154
ret void
228155
}
229156

230-
define void @implied4(i32 %n) {
231-
; Prove that (n s>= -1) ===> (n / 2 s>= 0).
232-
; CHECK-LABEL: 'implied4'
233-
; CHECK-NEXT: Determining loop execution counts for: @implied4
157+
define void @test_4(i32 %n) nounwind {
158+
; Prove that (n >= -1) ===> (n / 2 >= 0).
159+
; CHECK-LABEL: 'test_4'
160+
; CHECK-NEXT: Determining loop execution counts for: @test_4
234161
; CHECK-NEXT: Loop %header: backedge-taken count is (1 + %n.div.2)<nsw>
235162
; CHECK-NEXT: Loop %header: constant max backedge-taken count is i32 1073741824
236163
; CHECK-NEXT: Loop %header: symbolic max backedge-taken count is (1 + %n.div.2)<nsw>
@@ -252,35 +179,10 @@ exit:
252179
ret void
253180
}
254181

255-
define void @implied4_samesign(i32 %n) {
256-
; Prove that (n >= -1) ===> (n / 2 s>= 0).
257-
; CHECK-LABEL: 'implied4_samesign'
258-
; CHECK-NEXT: Determining loop execution counts for: @implied4_samesign
259-
; CHECK-NEXT: Loop %header: backedge-taken count is (1 + %n.div.2)<nsw>
260-
; CHECK-NEXT: Loop %header: constant max backedge-taken count is i32 1
261-
; CHECK-NEXT: Loop %header: symbolic max backedge-taken count is (1 + %n.div.2)<nsw>
262-
; CHECK-NEXT: Loop %header: Trip multiple is 1
263-
;
264-
entry:
265-
%cmp1 = icmp samesign uge i32 %n, -1
266-
%n.div.2 = sdiv i32 %n, 2
267-
call void @llvm.assume(i1 %cmp1)
268-
br label %header
269-
270-
header:
271-
%indvar = phi i32 [ %indvar.next, %header ], [ 0, %entry ]
272-
%indvar.next = add i32 %indvar, 1
273-
%exitcond = icmp sge i32 %n.div.2, %indvar
274-
br i1 %exitcond, label %header, label %exit
275-
276-
exit:
277-
ret void
278-
}
279-
280-
define void @implied4_neg(i32 %n) {
281-
; Prove that (n s>= -2) =\=> (n / 2 s>= 0).
282-
; CHECK-LABEL: 'implied4_neg'
283-
; CHECK-NEXT: Determining loop execution counts for: @implied4_neg
182+
define void @test_4neg(i32 %n) nounwind {
183+
; Prove that (n >= -2) =\=> (n / 2 >= 0).
184+
; CHECK-LABEL: 'test_4neg'
185+
; CHECK-NEXT: Determining loop execution counts for: @test_4neg
284186
; CHECK-NEXT: Loop %header: backedge-taken count is (0 smax (1 + %n.div.2)<nsw>)
285187
; CHECK-NEXT: Loop %header: constant max backedge-taken count is i32 1073741824
286188
; CHECK-NEXT: Loop %header: symbolic max backedge-taken count is (0 smax (1 + %n.div.2)<nsw>)

llvm/test/Transforms/IndVarSimplify/iv-ext-samesign.ll

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,32 +68,28 @@ define i32 @iv_zext_zext_gt_slt(i32 %iter.count, ptr %ptr) {
6868
; CHECK-LABEL: define i32 @iv_zext_zext_gt_slt(
6969
; CHECK-SAME: i32 [[ITER_COUNT:%.*]], ptr [[PTR:%.*]]) {
7070
; CHECK-NEXT: [[ENTRY:.*]]:
71-
; CHECK-NEXT: [[TMP0:%.*]] = add nsw i32 [[ITER_COUNT]], -1
71+
; CHECK-NEXT: [[TMP0:%.*]] = sext i32 [[ITER_COUNT]] to i64
7272
; CHECK-NEXT: br label %[[OUTER_LOOP:.*]]
7373
; CHECK: [[PH_LOOPEXIT:.*]]:
7474
; CHECK-NEXT: br label %[[PH:.*]]
7575
; CHECK: [[PH]]:
76-
; CHECK-NEXT: [[INDVARS_IV_NEXT3:%.*]] = add i32 [[INDVARS_IV1:%.*]], -1
7776
; CHECK-NEXT: br label %[[OUTER_LOOP]]
7877
; CHECK: [[OUTER_LOOP]]:
79-
; CHECK-NEXT: [[INDVARS_IV1]] = phi i32 [ [[INDVARS_IV_NEXT3]], %[[PH]] ], [ [[TMP0]], %[[ENTRY]] ]
80-
; CHECK-NEXT: [[IV_OUTER:%.*]] = phi i32 [ [[IV_OUTER_1:%.*]], %[[PH]] ], [ [[ITER_COUNT]], %[[ENTRY]] ]
81-
; CHECK-NEXT: [[IV_OUTER_1]] = add nsw i32 [[IV_OUTER]], -1
82-
; CHECK-NEXT: [[INDVARS_IV_NEXT2:%.*]] = zext nneg i32 [[IV_OUTER_1]] to i64
78+
; CHECK-NEXT: [[INDVARS_IV1:%.*]] = phi i64 [ [[INDVARS_IV_NEXT2:%.*]], %[[PH]] ], [ [[TMP0]], %[[ENTRY]] ]
79+
; CHECK-NEXT: [[INDVARS_IV_NEXT2]] = add nsw i64 [[INDVARS_IV1]], -1
8380
; CHECK-NEXT: [[GEP_OUTER:%.*]] = getelementptr i8, ptr [[PTR]], i64 [[INDVARS_IV_NEXT2]]
8481
; CHECK-NEXT: store i8 0, ptr [[GEP_OUTER]], align 1
85-
; CHECK-NEXT: [[EXIT_COND_OUTER:%.*]] = icmp samesign ugt i32 [[IV_OUTER]], 1
82+
; CHECK-NEXT: [[EXIT_COND_OUTER:%.*]] = icmp samesign ugt i64 [[INDVARS_IV1]], 1
8683
; CHECK-NEXT: br i1 [[EXIT_COND_OUTER]], label %[[INNER_LOOP_PREHEADER:.*]], label %[[PH]]
8784
; CHECK: [[INNER_LOOP_PREHEADER]]:
88-
; CHECK-NEXT: [[WIDE_TRIP_COUNT:%.*]] = zext i32 [[INDVARS_IV1]] to i64
8985
; CHECK-NEXT: br label %[[INNER_LOOP:.*]]
9086
; CHECK: [[INNER_LOOP]]:
9187
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, %[[INNER_LOOP_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], %[[INNER_LOOP]] ]
9288
; CHECK-NEXT: [[GEP_INNER:%.*]] = getelementptr i8, ptr [[PTR]], i64 [[INDVARS_IV]]
9389
; CHECK-NEXT: store i8 0, ptr [[GEP_INNER]], align 1
9490
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
95-
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], [[WIDE_TRIP_COUNT]]
96-
; CHECK-NEXT: br i1 [[EXITCOND]], label %[[INNER_LOOP]], label %[[PH_LOOPEXIT]]
91+
; CHECK-NEXT: [[EXIT_COND_INNER:%.*]] = icmp slt i64 [[INDVARS_IV_NEXT]], [[INDVARS_IV_NEXT2]]
92+
; CHECK-NEXT: br i1 [[EXIT_COND_INNER]], label %[[INNER_LOOP]], label %[[PH_LOOPEXIT]]
9793
; CHECK: [[EXIT:.*:]]
9894
; CHECK-NEXT: ret i32 0
9995
;
@@ -428,32 +424,28 @@ define i32 @iv_sext_sext_gt_slt(i32 %iter.count, ptr %ptr) {
428424
; CHECK-LABEL: define i32 @iv_sext_sext_gt_slt(
429425
; CHECK-SAME: i32 [[ITER_COUNT:%.*]], ptr [[PTR:%.*]]) {
430426
; CHECK-NEXT: [[ENTRY:.*]]:
431-
; CHECK-NEXT: [[TMP1:%.*]] = add nsw i32 [[ITER_COUNT]], -1
432427
; CHECK-NEXT: [[TMP0:%.*]] = sext i32 [[ITER_COUNT]] to i64
433428
; CHECK-NEXT: br label %[[OUTER_LOOP:.*]]
434429
; CHECK: [[PH_LOOPEXIT:.*]]:
435430
; CHECK-NEXT: br label %[[PH:.*]]
436431
; CHECK: [[PH]]:
437-
; CHECK-NEXT: [[INDVARS_IV_NEXT3:%.*]] = add i32 [[INDVARS_IV2:%.*]], -1
438432
; CHECK-NEXT: br label %[[OUTER_LOOP]]
439433
; CHECK: [[OUTER_LOOP]]:
440434
; CHECK-NEXT: [[INDVARS_IV1:%.*]] = phi i64 [ [[INDVARS_IV_NEXT2:%.*]], %[[PH]] ], [ [[TMP0]], %[[ENTRY]] ]
441-
; CHECK-NEXT: [[INDVARS_IV2]] = phi i32 [ [[INDVARS_IV_NEXT3]], %[[PH]] ], [ [[TMP1]], %[[ENTRY]] ]
442435
; CHECK-NEXT: [[INDVARS_IV_NEXT2]] = add nsw i64 [[INDVARS_IV1]], -1
443436
; CHECK-NEXT: [[GEP_OUTER:%.*]] = getelementptr i8, ptr [[PTR]], i64 [[INDVARS_IV_NEXT2]]
444437
; CHECK-NEXT: store i8 0, ptr [[GEP_OUTER]], align 1
445438
; CHECK-NEXT: [[EXIT_COND_OUTER:%.*]] = icmp samesign ugt i64 [[INDVARS_IV1]], 1
446439
; CHECK-NEXT: br i1 [[EXIT_COND_OUTER]], label %[[INNER_LOOP_PREHEADER:.*]], label %[[PH]]
447440
; CHECK: [[INNER_LOOP_PREHEADER]]:
448-
; CHECK-NEXT: [[WIDE_TRIP_COUNT:%.*]] = zext i32 [[INDVARS_IV2]] to i64
449441
; CHECK-NEXT: br label %[[INNER_LOOP:.*]]
450442
; CHECK: [[INNER_LOOP]]:
451443
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, %[[INNER_LOOP_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], %[[INNER_LOOP]] ]
452444
; CHECK-NEXT: [[GEP_INNER:%.*]] = getelementptr i8, ptr [[PTR]], i64 [[INDVARS_IV]]
453445
; CHECK-NEXT: store i8 0, ptr [[GEP_INNER]], align 1
454446
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
455-
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], [[WIDE_TRIP_COUNT]]
456-
; CHECK-NEXT: br i1 [[EXITCOND]], label %[[INNER_LOOP]], label %[[PH_LOOPEXIT]]
447+
; CHECK-NEXT: [[EXIT_COND_INNER:%.*]] = icmp slt i64 [[INDVARS_IV_NEXT]], [[INDVARS_IV_NEXT2]]
448+
; CHECK-NEXT: br i1 [[EXIT_COND_INNER]], label %[[INNER_LOOP]], label %[[PH_LOOPEXIT]]
457449
; CHECK: [[EXIT:.*:]]
458450
; CHECK-NEXT: ret i32 0
459451
;

0 commit comments

Comments
 (0)