1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=indvars -S -indvars-predicate-loops=0 | FileCheck %s
4 ; Make sure that indvars isn't inserting canonical IVs.
5 ; This is kinda hard to do until linear function test replacement is removed.
7 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
9 ; We should only have 2 IVs.
10 ; sext should be eliminated while preserving gep inboundsness.
11 define i32 @sum(ptr %arr, i32 %n) nounwind {
14 ; CHECK-NEXT: [[PRECOND:%.*]] = icmp slt i32 0, [[N:%.*]]
15 ; CHECK-NEXT: br i1 [[PRECOND]], label [[PH:%.*]], label [[RETURN:%.*]]
17 ; CHECK-NEXT: [[WIDE_TRIP_COUNT:%.*]] = zext i32 [[N]] to i64
18 ; CHECK-NEXT: br label [[LOOP:%.*]]
20 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ], [ 0, [[PH]] ]
21 ; CHECK-NEXT: [[S_01:%.*]] = phi i32 [ 0, [[PH]] ], [ [[SINC:%.*]], [[LOOP]] ]
22 ; CHECK-NEXT: [[ADR:%.*]] = getelementptr inbounds i32, ptr [[ARR:%.*]], i64 [[INDVARS_IV]]
23 ; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[ADR]], align 4
24 ; CHECK-NEXT: [[SINC]] = add nsw i32 [[S_01]], [[VAL]]
25 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
26 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], [[WIDE_TRIP_COUNT]]
27 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[EXIT:%.*]]
29 ; CHECK-NEXT: [[S_LCSSA:%.*]] = phi i32 [ [[SINC]], [[LOOP]] ]
30 ; CHECK-NEXT: br label [[RETURN]]
32 ; CHECK-NEXT: [[S_0_LCSSA:%.*]] = phi i32 [ [[S_LCSSA]], [[EXIT]] ], [ 0, [[ENTRY:%.*]] ]
33 ; CHECK-NEXT: ret i32 [[S_0_LCSSA]]
36 %precond = icmp slt i32 0, %n
37 br i1 %precond, label %ph, label %return
43 %i.02 = phi i32 [ 0, %ph ], [ %iinc, %loop ]
44 %s.01 = phi i32 [ 0, %ph ], [ %sinc, %loop ]
45 %ofs = sext i32 %i.02 to i64
46 %adr = getelementptr inbounds i32, ptr %arr, i64 %ofs
47 %val = load i32, ptr %adr
48 %sinc = add nsw i32 %s.01, %val
49 %iinc = add nsw i32 %i.02, 1
50 %cond = icmp slt i32 %iinc, %n
51 br i1 %cond, label %loop, label %exit
54 %s.lcssa = phi i32 [ %sinc, %loop ]
58 %s.0.lcssa = phi i32 [ %s.lcssa, %exit ], [ 0, %entry ]
62 ; We should only have 2 IVs.
63 ; %ofs sext should be eliminated while preserving gep inboundsness.
64 ; %vall sext should obviously not be eliminated
65 define i64 @suml(ptr %arr, i32 %n) nounwind {
68 ; CHECK-NEXT: [[PRECOND:%.*]] = icmp slt i32 0, [[N:%.*]]
69 ; CHECK-NEXT: br i1 [[PRECOND]], label [[PH:%.*]], label [[RETURN:%.*]]
71 ; CHECK-NEXT: [[WIDE_TRIP_COUNT:%.*]] = zext i32 [[N]] to i64
72 ; CHECK-NEXT: br label [[LOOP:%.*]]
74 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ], [ 0, [[PH]] ]
75 ; CHECK-NEXT: [[S_01:%.*]] = phi i64 [ 0, [[PH]] ], [ [[SINC:%.*]], [[LOOP]] ]
76 ; CHECK-NEXT: [[ADR:%.*]] = getelementptr inbounds i32, ptr [[ARR:%.*]], i64 [[INDVARS_IV]]
77 ; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[ADR]], align 4
78 ; CHECK-NEXT: [[VALL:%.*]] = sext i32 [[VAL]] to i64
79 ; CHECK-NEXT: [[SINC]] = add nsw i64 [[S_01]], [[VALL]]
80 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
81 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], [[WIDE_TRIP_COUNT]]
82 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[EXIT:%.*]]
84 ; CHECK-NEXT: [[S_LCSSA:%.*]] = phi i64 [ [[SINC]], [[LOOP]] ]
85 ; CHECK-NEXT: br label [[RETURN]]
87 ; CHECK-NEXT: [[S_0_LCSSA:%.*]] = phi i64 [ [[S_LCSSA]], [[EXIT]] ], [ 0, [[ENTRY:%.*]] ]
88 ; CHECK-NEXT: ret i64 [[S_0_LCSSA]]
91 %precond = icmp slt i32 0, %n
92 br i1 %precond, label %ph, label %return
98 %i.02 = phi i32 [ 0, %ph ], [ %iinc, %loop ]
99 %s.01 = phi i64 [ 0, %ph ], [ %sinc, %loop ]
100 %ofs = sext i32 %i.02 to i64
101 %adr = getelementptr inbounds i32, ptr %arr, i64 %ofs
102 %val = load i32, ptr %adr
103 %vall = sext i32 %val to i64
104 %sinc = add nsw i64 %s.01, %vall
105 %iinc = add nsw i32 %i.02, 1
106 %cond = icmp slt i32 %iinc, %n
107 br i1 %cond, label %loop, label %exit
110 %s.lcssa = phi i64 [ %sinc, %loop ]
114 %s.0.lcssa = phi i64 [ %s.lcssa, %exit ], [ 0, %entry ]
118 ; It's not indvars' job to perform LICM on %ofs
119 ; Preserve exactly one pointer type IV.
120 ; Don't create any extra adds.
121 ; Preserve gep inboundsness, and don't factor it.
122 define void @outofbounds(ptr %first, ptr %last, i32 %idx) nounwind {
123 ; CHECK-LABEL: @outofbounds(
124 ; CHECK-NEXT: [[PRECOND:%.*]] = icmp ne ptr [[FIRST:%.*]], [[LAST:%.*]]
125 ; CHECK-NEXT: br i1 [[PRECOND]], label [[PH:%.*]], label [[RETURN:%.*]]
127 ; CHECK-NEXT: br label [[LOOP:%.*]]
129 ; CHECK-NEXT: [[PTRIV:%.*]] = phi ptr [ [[FIRST]], [[PH]] ], [ [[PTRPOST:%.*]], [[LOOP]] ]
130 ; CHECK-NEXT: [[OFS:%.*]] = sext i32 [[IDX:%.*]] to i64
131 ; CHECK-NEXT: [[ADR:%.*]] = getelementptr inbounds i32, ptr [[PTRIV]], i64 [[OFS]]
132 ; CHECK-NEXT: store i32 3, ptr [[ADR]], align 4
133 ; CHECK-NEXT: [[PTRPOST]] = getelementptr inbounds i32, ptr [[PTRIV]], i32 1
134 ; CHECK-NEXT: [[COND:%.*]] = icmp ne ptr [[PTRPOST]], [[LAST]]
135 ; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]]
137 ; CHECK-NEXT: br label [[RETURN]]
139 ; CHECK-NEXT: ret void
141 %precond = icmp ne ptr %first, %last
142 br i1 %precond, label %ph, label %return
148 %ptriv = phi ptr [ %first, %ph ], [ %ptrpost, %loop ]
149 %ofs = sext i32 %idx to i64
150 %adr = getelementptr inbounds i32, ptr %ptriv, i64 %ofs
151 store i32 3, ptr %adr
152 %ptrpost = getelementptr inbounds i32, ptr %ptriv, i32 1
153 %cond = icmp ne ptr %ptrpost, %last
154 br i1 %cond, label %loop, label %exit
163 %structI = type { i32 }
166 define void @bitcastiv(i32 %start, i32 %limit, i32 %step, ptr %base)
167 ; CHECK-LABEL: @bitcastiv(
169 ; CHECK-NEXT: br label [[LOOP:%.*]]
171 ; CHECK-NEXT: [[IV:%.*]] = phi i32 [ [[START:%.*]], [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
172 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[BASE:%.*]], [[ENTRY]] ], [ [[PINC:%.*]], [[LOOP]] ]
173 ; CHECK-NEXT: store i32 3, ptr [[P]], align 4
174 ; CHECK-NEXT: store i32 4, ptr [[P]], align 4
175 ; CHECK-NEXT: [[PINC]] = getelementptr [[STRUCTI:%.*]], ptr [[P]], i32 1
176 ; CHECK-NEXT: [[NEXT]] = add i32 [[IV]], 1
177 ; CHECK-NEXT: [[COND:%.*]] = icmp ne i32 [[NEXT]], [[LIMIT:%.*]]
178 ; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]]
180 ; CHECK-NEXT: ret void
188 %iv = phi i32 [%start, %entry], [%next, %loop]
189 %p = phi ptr [%base, %entry], [%pinc, %loop]
192 %pinc = getelementptr %structI, ptr %p, i32 1
193 %next = add i32 %iv, 1
194 %cond = icmp ne i32 %next, %limit
195 br i1 %cond, label %loop, label %exit
201 ; Test inserting a truncate at a phi use.
202 define void @maxvisitor(i32 %limit, ptr %base) nounwind {
203 ; CHECK-LABEL: @maxvisitor(
205 ; CHECK-NEXT: [[SMAX:%.*]] = call i32 @llvm.smax.i32(i32 [[LIMIT:%.*]], i32 1)
206 ; CHECK-NEXT: [[WIDE_TRIP_COUNT:%.*]] = zext i32 [[SMAX]] to i64
207 ; CHECK-NEXT: br label [[LOOP:%.*]]
209 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], [[LOOP_INC:%.*]] ], [ 0, [[ENTRY:%.*]] ]
210 ; CHECK-NEXT: [[MAX:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[MAX_NEXT:%.*]], [[LOOP_INC]] ]
211 ; CHECK-NEXT: [[ADR:%.*]] = getelementptr inbounds i32, ptr [[BASE:%.*]], i64 [[INDVARS_IV]]
212 ; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[ADR]], align 4
213 ; CHECK-NEXT: [[CMP19:%.*]] = icmp sgt i32 [[VAL]], [[MAX]]
214 ; CHECK-NEXT: br i1 [[CMP19]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
216 ; CHECK-NEXT: [[TMP0:%.*]] = trunc i64 [[INDVARS_IV]] to i32
217 ; CHECK-NEXT: br label [[LOOP_INC]]
219 ; CHECK-NEXT: br label [[LOOP_INC]]
221 ; CHECK-NEXT: [[MAX_NEXT]] = phi i32 [ [[TMP0]], [[IF_THEN]] ], [ [[MAX]], [[IF_ELSE]] ]
222 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
223 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], [[WIDE_TRIP_COUNT]]
224 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[EXIT:%.*]]
226 ; CHECK-NEXT: ret void
232 %idx = phi i32 [ 0, %entry ], [ %idx.next, %loop.inc ]
233 %max = phi i32 [ 0, %entry ], [ %max.next, %loop.inc ]
234 %idxprom = sext i32 %idx to i64
235 %adr = getelementptr inbounds i32, ptr %base, i64 %idxprom
236 %val = load i32, ptr %adr
237 %cmp19 = icmp sgt i32 %val, %max
238 br i1 %cmp19, label %if.then, label %if.else
247 %max.next = phi i32 [ %idx, %if.then ], [ %max, %if.else ]
248 %idx.next = add nsw i32 %idx, 1
249 %cmp = icmp slt i32 %idx.next, %limit
250 br i1 %cmp, label %loop, label %exit
256 ; Test an edge case of removing an identity phi that directly feeds
257 ; back to the loop iv.
258 define void @identityphi(i32 %limit) nounwind {
259 ; CHECK-LABEL: @identityphi(
261 ; CHECK-NEXT: br label [[LOOP:%.*]]
263 ; CHECK-NEXT: br i1 undef, label [[IF_THEN:%.*]], label [[CONTROL:%.*]]
265 ; CHECK-NEXT: br label [[CONTROL]]
267 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 0, [[LIMIT:%.*]]
268 ; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[EXIT:%.*]]
270 ; CHECK-NEXT: ret void
276 %iv = phi i32 [ 0, %entry], [ %iv.next, %control ]
277 br i1 undef, label %if.then, label %control
283 %iv.next = phi i32 [ %iv, %loop ], [ undef, %if.then ]
284 %cmp = icmp slt i32 %iv.next, %limit
285 br i1 %cmp, label %loop, label %exit
291 ; Test cloning an or, which is not an OverflowBinaryOperator.
292 define i64 @cloneOr(i32 %limit, ptr %base) nounwind {
293 ; CHECK-LABEL: @cloneOr(
295 ; CHECK-NEXT: [[HALFLIM:%.*]] = ashr i32 [[LIMIT:%.*]], 2
296 ; CHECK-NEXT: [[TMP0:%.*]] = sext i32 [[HALFLIM]] to i64
297 ; CHECK-NEXT: br label [[LOOP:%.*]]
299 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ], [ 0, [[ENTRY:%.*]] ]
300 ; CHECK-NEXT: [[ADR:%.*]] = getelementptr i64, ptr [[BASE:%.*]], i64 [[INDVARS_IV]]
301 ; CHECK-NEXT: [[VAL:%.*]] = load i64, ptr [[ADR]], align 8
302 ; CHECK-NEXT: [[TMP1:%.*]] = or disjoint i64 [[INDVARS_IV]], 1
303 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 2
304 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[INDVARS_IV_NEXT]], [[TMP0]]
305 ; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[EXIT:%.*]]
307 ; CHECK-NEXT: [[VAL_LCSSA:%.*]] = phi i64 [ [[VAL]], [[LOOP]] ]
308 ; CHECK-NEXT: [[T3_LCSSA:%.*]] = phi i64 [ [[TMP1]], [[LOOP]] ]
309 ; CHECK-NEXT: [[RESULT:%.*]] = and i64 [[VAL_LCSSA]], [[T3_LCSSA]]
310 ; CHECK-NEXT: ret i64 [[RESULT]]
313 ; ensure that the loop can't overflow
314 %halfLim = ashr i32 %limit, 2
318 %iv = phi i32 [ 0, %entry], [ %iv.next, %loop ]
319 %t1 = sext i32 %iv to i64
320 %adr = getelementptr i64, ptr %base, i64 %t1
321 %val = load i64, ptr %adr
322 %t2 = or disjoint i32 %iv, 1
323 %t3 = sext i32 %t2 to i64
324 %iv.next = add i32 %iv, 2
325 %cmp = icmp slt i32 %iv.next, %halfLim
326 br i1 %cmp, label %loop, label %exit
329 %result = and i64 %val, %t3
333 ; The i induction variable looks like a wrap-around, but it really is just
334 ; a simple affine IV. Make sure that indvars simplifies through.
335 ; ReplaceLoopExitValue should fold the return value to constant 9.
336 define i32 @indirectRecurrence() nounwind {
337 ; CHECK-LABEL: @indirectRecurrence(
339 ; CHECK-NEXT: br label [[LOOP:%.*]]
341 ; CHECK-NEXT: [[J_0:%.*]] = phi i32 [ 1, [[ENTRY:%.*]] ], [ [[J_NEXT:%.*]], [[COND_TRUE:%.*]] ]
342 ; CHECK-NEXT: [[TMP:%.*]] = icmp ne i32 [[J_0]], 10
343 ; CHECK-NEXT: br i1 [[TMP]], label [[COND_TRUE]], label [[RETURN:%.*]]
345 ; CHECK-NEXT: [[J_NEXT]] = add nuw nsw i32 [[J_0]], 1
346 ; CHECK-NEXT: br label [[LOOP]]
348 ; CHECK-NEXT: ret i32 9
354 %j.0 = phi i32 [ 1, %entry ], [ %j.next, %cond_true ]
355 %i.0 = phi i32 [ 0, %entry ], [ %j.0, %cond_true ]
356 %tmp = icmp ne i32 %j.0, 10
357 br i1 %tmp, label %cond_true, label %return
360 %j.next = add i32 %j.0, 1
367 ; Eliminate the congruent phis j, k, and l.
368 ; Eliminate the redundant IV increments k.next and l.next.
369 ; Two phis should remain, one starting at %init, and one at %init1.
370 ; Two increments should remain, one by %step and one by %step1.
371 ; Five live-outs should remain.
372 define i32 @isomorphic(i32 %init, i32 %step, i32 %lim) nounwind {
373 ; CHECK-LABEL: @isomorphic(
375 ; CHECK-NEXT: [[STEP1:%.*]] = add i32 [[STEP:%.*]], 1
376 ; CHECK-NEXT: [[INIT1:%.*]] = add i32 [[INIT:%.*]], [[STEP1]]
377 ; CHECK-NEXT: br label [[LOOP:%.*]]
379 ; CHECK-NEXT: [[II:%.*]] = phi i32 [ [[INIT1]], [[ENTRY:%.*]] ], [ [[II_NEXT:%.*]], [[LOOP]] ]
380 ; CHECK-NEXT: [[J:%.*]] = phi i32 [ [[INIT]], [[ENTRY]] ], [ [[J_NEXT:%.*]], [[LOOP]] ]
381 ; CHECK-NEXT: [[II_NEXT]] = add i32 [[II]], [[STEP1]]
382 ; CHECK-NEXT: [[J_NEXT]] = add i32 [[J]], [[STEP1]]
383 ; CHECK-NEXT: [[L_STEP:%.*]] = add i32 [[J]], [[STEP]]
384 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[II_NEXT]], [[LIM:%.*]]
385 ; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[RETURN:%.*]]
387 ; CHECK-NEXT: [[I_LCSSA:%.*]] = phi i32 [ [[J]], [[LOOP]] ]
388 ; CHECK-NEXT: [[J_NEXT_LCSSA:%.*]] = phi i32 [ [[J_NEXT]], [[LOOP]] ]
389 ; CHECK-NEXT: [[K_NEXT_LCSSA:%.*]] = phi i32 [ [[II_NEXT]], [[LOOP]] ]
390 ; CHECK-NEXT: [[L_STEP_LCSSA:%.*]] = phi i32 [ [[L_STEP]], [[LOOP]] ]
391 ; CHECK-NEXT: [[L_NEXT_LCSSA:%.*]] = phi i32 [ [[J_NEXT]], [[LOOP]] ]
392 ; CHECK-NEXT: [[SUM1:%.*]] = add i32 [[I_LCSSA]], [[J_NEXT_LCSSA]]
393 ; CHECK-NEXT: [[SUM2:%.*]] = add i32 [[SUM1]], [[K_NEXT_LCSSA]]
394 ; CHECK-NEXT: [[SUM3:%.*]] = add i32 [[SUM1]], [[L_STEP_LCSSA]]
395 ; CHECK-NEXT: [[SUM4:%.*]] = add i32 [[SUM1]], [[L_NEXT_LCSSA]]
396 ; CHECK-NEXT: ret i32 [[SUM4]]
399 %step1 = add i32 %step, 1
400 %init1 = add i32 %init, %step1
401 %l.0 = sub i32 %init1, %step1
405 %ii = phi i32 [ %init1, %entry ], [ %ii.next, %loop ]
406 %i = phi i32 [ %init, %entry ], [ %ii, %loop ]
407 %j = phi i32 [ %init, %entry ], [ %j.next, %loop ]
408 %k = phi i32 [ %init1, %entry ], [ %k.next, %loop ]
409 %l = phi i32 [ %l.0, %entry ], [ %l.next, %loop ]
410 %ii.next = add i32 %ii, %step1
411 %j.next = add i32 %j, %step1
412 %k.next = add i32 %k, %step1
413 %l.step = add i32 %l, %step
414 %l.next = add i32 %l.step, 1
415 %cmp = icmp ne i32 %ii.next, %lim
416 br i1 %cmp, label %loop, label %return
419 %sum1 = add i32 %i, %j.next
420 %sum2 = add i32 %sum1, %k.next
421 %sum3 = add i32 %sum1, %l.step
422 %sum4 = add i32 %sum1, %l.next
426 ; Test a GEP IV that is derived from another GEP IV by a nop gep that
427 ; lowers the type without changing the expression.
428 %structIF = type { i32, float }
430 define void @congruentgepiv(ptr %base) nounwind uwtable ssp {
431 ; CHECK-LABEL: @congruentgepiv(
433 ; CHECK-NEXT: br label [[LOOP:%.*]]
435 ; CHECK-NEXT: store i32 4, ptr [[BASE:%.*]], align 4
436 ; CHECK-NEXT: br i1 false, label [[LATCH:%.*]], label [[EXIT:%.*]]
438 ; CHECK-NEXT: br label [[LOOP]]
440 ; CHECK-NEXT: ret void
446 %ptr.iv = phi ptr [ %ptr.inc, %latch ], [ %base, %entry ]
447 %next = phi ptr [ %next, %latch ], [ %base, %entry ]
448 store i32 4, ptr %next
449 br i1 undef, label %latch, label %exit
451 latch: ; preds = %for.inc50.i
452 %ptr.inc = getelementptr inbounds %structIF, ptr %ptr.iv, i64 1
459 declare void @use32(i32 %x)
460 declare void @use64(i64 %x)
462 ; Test a widened IV that is used by a phi on different paths within the loop.
463 define void @phiUsesTrunc() nounwind {
464 ; CHECK-LABEL: @phiUsesTrunc(
466 ; CHECK-NEXT: br i1 undef, label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_END:%.*]]
467 ; CHECK: for.body.preheader:
468 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
470 ; CHECK-NEXT: br i1 undef, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
472 ; CHECK-NEXT: br i1 undef, label [[IF_THEN33:%.*]], label [[FOR_INC:%.*]]
474 ; CHECK-NEXT: br label [[FOR_INC]]
476 ; CHECK-NEXT: br i1 undef, label [[IF_THEN97:%.*]], label [[FOR_INC]]
478 ; CHECK-NEXT: call void @use64(i64 1)
479 ; CHECK-NEXT: br label [[FOR_INC]]
481 ; CHECK-NEXT: [[KMIN_1:%.*]] = phi i32 [ 1, [[IF_THEN33]] ], [ 0, [[IF_THEN]] ], [ 1, [[IF_THEN97]] ], [ 0, [[IF_ELSE]] ]
482 ; CHECK-NEXT: call void @use32(i32 [[KMIN_1]])
483 ; CHECK-NEXT: br i1 false, label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]]
484 ; CHECK: for.end.loopexit:
485 ; CHECK-NEXT: br label [[FOR_END]]
487 ; CHECK-NEXT: ret void
490 br i1 undef, label %for.body, label %for.end
493 %iv = phi i32 [ %inc, %for.inc ], [ 1, %entry ]
494 br i1 undef, label %if.then, label %if.else
497 br i1 undef, label %if.then33, label %for.inc
503 br i1 undef, label %if.then97, label %for.inc
506 %idxprom100 = sext i32 %iv to i64
507 call void @use64(i64 %idxprom100)
511 %kmin.1 = phi i32 [ %iv, %if.then33 ], [ 0, %if.then ], [ %iv, %if.then97 ], [ 0, %if.else ]
512 call void @use32(i32 %kmin.1)
513 %inc = add nsw i32 %iv, 1
514 br i1 undef, label %for.body, label %for.end