1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -indvars -S < %s | FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 ; General case: without extra knowledge, trunc cannot be eliminated.
8 define void @test_00(i64 %start, i32 %n) {
10 ; CHECK-LABEL: @test_00(
12 ; CHECK-NEXT: br label [[LOOP:%.*]]
14 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[START:%.*]], [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
15 ; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
16 ; CHECK-NEXT: [[NARROW_IV:%.*]] = trunc i64 [[IV]] to i32
17 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[NARROW_IV]], [[N:%.*]]
18 ; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[EXIT:%.*]]
20 ; CHECK-NEXT: ret void
25 %iv = phi i64 [ %start, %entry ], [ %iv.next, %loop ]
26 %iv.next = add i64 %iv, 1
27 %narrow.iv = trunc i64 %iv to i32
28 %cmp = icmp slt i32 %narrow.iv, %n
29 br i1 %cmp, label %loop, label %exit
35 define void @test_01(i32 %n) {
37 ; CHECK-LABEL: @test_01(
39 ; CHECK-NEXT: [[SEXT:%.*]] = sext i32 [[N:%.*]] to i64
40 ; CHECK-NEXT: br label [[LOOP:%.*]]
42 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
43 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
44 ; CHECK-NEXT: [[TMP0:%.*]] = icmp slt i64 [[IV]], [[SEXT]]
45 ; CHECK-NEXT: br i1 [[TMP0]], label [[LOOP]], label [[EXIT:%.*]]
47 ; CHECK-NEXT: ret void
52 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
53 %iv.next = add i64 %iv, 1
54 %narrow.iv = trunc i64 %iv to i32
55 %cmp = icmp slt i32 %narrow.iv, %n
56 br i1 %cmp, label %loop, label %exit
61 ; Max value at which we can eliminate trunc: SINT_MAX - 1.
62 define void @test_02(i32 %n) {
64 ; CHECK-LABEL: @test_02(
66 ; CHECK-NEXT: [[SEXT:%.*]] = sext i32 [[N:%.*]] to i64
67 ; CHECK-NEXT: br label [[LOOP:%.*]]
69 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 2147483646, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
70 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
71 ; CHECK-NEXT: [[TMP0:%.*]] = icmp slt i64 [[IV]], [[SEXT]]
72 ; CHECK-NEXT: br i1 [[TMP0]], label [[LOOP]], label [[EXIT:%.*]]
74 ; CHECK-NEXT: ret void
79 %iv = phi i64 [ 2147483646, %entry ], [ %iv.next, %loop ]
80 %iv.next = add i64 %iv, 1
81 %narrow.iv = trunc i64 %iv to i32
82 %cmp = icmp slt i32 %narrow.iv, %n
83 br i1 %cmp, label %loop, label %exit
88 ; If we start from SINT_MAX then the predicate is always false.
89 define void @test_03(i32 %n) {
91 ; CHECK-LABEL: @test_03(
93 ; CHECK-NEXT: br label [[LOOP:%.*]]
95 ; CHECK-NEXT: br i1 false, label [[LOOP]], label [[EXIT:%.*]]
97 ; CHECK-NEXT: ret void
102 %iv = phi i64 [2147483647, %entry], [%iv.next, %loop]
103 %iv.next = add i64 %iv, 1
104 %narrow.iv = trunc i64 %iv to i32
105 %cmp = icmp slt i32 %narrow.iv, %n
106 br i1 %cmp, label %loop, label %exit
111 ; Minimum value at which we can apply the transform: SINT_MIN + 1.
112 define void @test_04(i32 %n) {
114 ; CHECK-LABEL: @test_04(
116 ; CHECK-NEXT: [[SEXT:%.*]] = sext i32 [[N:%.*]] to i64
117 ; CHECK-NEXT: br label [[LOOP:%.*]]
119 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ -2147483647, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
120 ; CHECK-NEXT: [[IV_NEXT]] = add nsw i64 [[IV]], 1
121 ; CHECK-NEXT: [[TMP0:%.*]] = icmp slt i64 [[IV]], [[SEXT]]
122 ; CHECK-NEXT: br i1 [[TMP0]], label [[LOOP]], label [[EXIT:%.*]]
124 ; CHECK-NEXT: ret void
129 %iv = phi i64 [ -2147483647, %entry ], [ %iv.next, %loop ]
130 %iv.next = add i64 %iv, 1
131 %narrow.iv = trunc i64 %iv to i32
132 %cmp = icmp slt i32 %narrow.iv, %n
133 br i1 %cmp, label %loop, label %exit
138 ; FIXME: Harmful LFTR should be thrown away.
139 define void @test_05(i32 %n) {
141 ; CHECK-LABEL: @test_05(
143 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[N:%.*]], 1
144 ; CHECK-NEXT: br label [[LOOP:%.*]]
146 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ -2147483648, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
147 ; CHECK-NEXT: [[IV_NEXT]] = add nsw i64 [[IV]], 1
148 ; CHECK-NEXT: [[LFTR_WIDEIV:%.*]] = trunc i64 [[IV_NEXT]] to i32
149 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[LFTR_WIDEIV]], [[TMP0]]
150 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[EXIT:%.*]]
152 ; CHECK-NEXT: ret void
157 %iv = phi i64 [ -2147483648, %entry ], [ %iv.next, %loop ]
158 %iv.next = add i64 %iv, 1
159 %narrow.iv = trunc i64 %iv to i32
160 %cmp = icmp slt i32 %narrow.iv, %n
161 br i1 %cmp, label %loop, label %exit
166 ; Trunc changes the actual value of the IV, so it is invalid to remove it: SINT_MIN - 1.
167 define void @test_06(i32 %n) {
169 ; CHECK-LABEL: @test_06(
171 ; CHECK-NEXT: br label [[LOOP:%.*]]
173 ; CHECK-NEXT: br i1 false, label [[LOOP]], label [[EXIT:%.*]]
175 ; CHECK-NEXT: ret void
180 %iv = phi i64 [ -2147483649, %entry ], [ %iv.next, %loop ]
181 %iv.next = add i64 %iv, 1
182 %narrow.iv = trunc i64 %iv to i32
183 %cmp = icmp slt i32 %narrow.iv, %n
184 br i1 %cmp, label %loop, label %exit
189 ; General case: without extra knowledge, trunc cannot be eliminated.
190 define void @test_00_unsigned(i64 %start, i32 %n) {
191 ; CHECK-LABEL: @test_00_unsigned(
193 ; CHECK-NEXT: br label [[LOOP:%.*]]
195 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[START:%.*]], [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
196 ; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
197 ; CHECK-NEXT: [[NARROW_IV:%.*]] = trunc i64 [[IV]] to i32
198 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[NARROW_IV]], [[N:%.*]]
199 ; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[EXIT:%.*]]
201 ; CHECK-NEXT: ret void
206 %iv = phi i64 [ %start, %entry ], [ %iv.next, %loop ]
207 %iv.next = add i64 %iv, 1
208 %narrow.iv = trunc i64 %iv to i32
209 %cmp = icmp ult i32 %narrow.iv, %n
210 br i1 %cmp, label %loop, label %exit
215 ; FIXME: Harmful LFTR should be thrown away.
216 define void @test_01_unsigned(i32 %n) {
217 ; CHECK-LABEL: @test_01_unsigned(
219 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[N:%.*]], 1
220 ; CHECK-NEXT: br label [[LOOP:%.*]]
222 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
223 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
224 ; CHECK-NEXT: [[LFTR_WIDEIV:%.*]] = trunc i64 [[IV_NEXT]] to i32
225 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[LFTR_WIDEIV]], [[TMP0]]
226 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[EXIT:%.*]]
228 ; CHECK-NEXT: ret void
233 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
234 %iv.next = add i64 %iv, 1
235 %narrow.iv = trunc i64 %iv to i32
236 %cmp = icmp ult i32 %narrow.iv, %n
237 br i1 %cmp, label %loop, label %exit
242 ; Max value at which we can eliminate trunc: UINT_MAX - 1.
243 define void @test_02_unsigned(i32 %n) {
244 ; CHECK-LABEL: @test_02_unsigned(
246 ; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 [[N:%.*]] to i64
247 ; CHECK-NEXT: br label [[LOOP:%.*]]
249 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 4294967294, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
250 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
251 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i64 [[IV]], [[ZEXT]]
252 ; CHECK-NEXT: br i1 [[TMP0]], label [[LOOP]], label [[EXIT:%.*]]
254 ; CHECK-NEXT: ret void
259 %iv = phi i64 [ 4294967294, %entry ], [ %iv.next, %loop ]
260 %iv.next = add i64 %iv, 1
261 %narrow.iv = trunc i64 %iv to i32
262 %cmp = icmp ult i32 %narrow.iv, %n
263 br i1 %cmp, label %loop, label %exit
268 ; If we start from UINT_MAX then the predicate is always false.
269 define void @test_03_unsigned(i32 %n) {
270 ; CHECK-LABEL: @test_03_unsigned(
272 ; CHECK-NEXT: br label [[LOOP:%.*]]
274 ; CHECK-NEXT: br i1 false, label [[LOOP]], label [[EXIT:%.*]]
276 ; CHECK-NEXT: ret void
281 %iv = phi i64 [ 4294967295, %entry ], [ %iv.next, %loop ]
282 %iv.next = add i64 %iv, 1
283 %narrow.iv = trunc i64 %iv to i32
284 %cmp = icmp ult i32 %narrow.iv, %n
285 br i1 %cmp, label %loop, label %exit
290 ; Minimum value at which we can apply the transform: UINT_MIN.
291 define void @test_04_unsigned(i32 %n) {
292 ; CHECK-LABEL: @test_04_unsigned(
294 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[N:%.*]], 1
295 ; CHECK-NEXT: br label [[LOOP:%.*]]
297 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
298 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
299 ; CHECK-NEXT: [[LFTR_WIDEIV:%.*]] = trunc i64 [[IV_NEXT]] to i32
300 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[LFTR_WIDEIV]], [[TMP0]]
301 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[EXIT:%.*]]
303 ; CHECK-NEXT: ret void
308 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
309 %iv.next = add i64 %iv, 1
310 %narrow.iv = trunc i64 %iv to i32
311 %cmp = icmp ult i32 %narrow.iv, %n
312 br i1 %cmp, label %loop, label %exit
318 define void @test_05_unsigned(i32 %n) {
319 ; CHECK-LABEL: @test_05_unsigned(
321 ; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 [[N:%.*]] to i64
322 ; CHECK-NEXT: br label [[LOOP:%.*]]
324 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 1, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
325 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
326 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i64 [[IV]], [[ZEXT]]
327 ; CHECK-NEXT: br i1 [[TMP0]], label [[LOOP]], label [[EXIT:%.*]]
329 ; CHECK-NEXT: ret void
334 %iv = phi i64 [ 1, %entry ], [ %iv.next, %loop ]
335 %iv.next = add i64 %iv, 1
336 %narrow.iv = trunc i64 %iv to i32
337 %cmp = icmp ult i32 %narrow.iv, %n
338 br i1 %cmp, label %loop, label %exit
343 ; Trunc changes the actual value of the IV, so it is invalid to remove it: UINT_MIN - 1.
344 define void @test_06_unsigned(i32 %n) {
345 ; CHECK-LABEL: @test_06_unsigned(
347 ; CHECK-NEXT: br label [[LOOP:%.*]]
349 ; CHECK-NEXT: br i1 false, label [[LOOP]], label [[EXIT:%.*]]
351 ; CHECK-NEXT: ret void
356 %iv = phi i64 [ -1, %entry ], [ %iv.next, %loop ]
357 %iv.next = add i64 %iv, 1
358 %narrow.iv = trunc i64 %iv to i32
359 %cmp = icmp ult i32 %narrow.iv, %n
360 br i1 %cmp, label %loop, label %exit
365 ; Do not eliminate trunc if it is used by something different from icmp.
366 define void @test_07(i32* %p, i32 %n) {
367 ; CHECK-LABEL: @test_07(
369 ; CHECK-NEXT: br label [[LOOP:%.*]]
371 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
372 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
373 ; CHECK-NEXT: [[NARROW_IV:%.*]] = trunc i64 [[IV]] to i32
374 ; CHECK-NEXT: store i32 [[NARROW_IV]], i32* [[P:%.*]]
375 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[NARROW_IV]], [[N:%.*]]
376 ; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[EXIT:%.*]]
378 ; CHECK-NEXT: ret void
383 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
384 %iv.next = add i64 %iv, 1
385 %narrow.iv = trunc i64 %iv to i32
386 store i32 %narrow.iv, i32* %p
387 %cmp = icmp slt i32 %narrow.iv, %n
388 br i1 %cmp, label %loop, label %exit
393 ; Check that we can eliminate both signed and unsigned compare.
394 define void @test_08(i32 %n) {
395 ; CHECK-LABEL: @test_08(
397 ; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 [[N:%.*]] to i64
398 ; CHECK-NEXT: [[SEXT:%.*]] = sext i32 [[N]] to i64
399 ; CHECK-NEXT: br label [[LOOP:%.*]]
401 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 1, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
402 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
403 ; CHECK-NEXT: [[TMP0:%.*]] = icmp slt i64 [[IV]], [[SEXT]]
404 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i64 [[IV]], [[ZEXT]]
405 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP0]], [[TMP1]]
406 ; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[EXIT:%.*]]
408 ; CHECK-NEXT: ret void
413 %iv = phi i64 [ 1, %entry ], [ %iv.next, %loop ]
414 %iv.next = add i64 %iv, 1
415 %narrow.iv = trunc i64 %iv to i32
416 %cmp1 = icmp slt i32 %narrow.iv, %n
417 %cmp2 = icmp ult i32 %narrow.iv, %n
418 %cmp = and i1 %cmp1, %cmp2
419 br i1 %cmp, label %loop, label %exit
424 ; Widen NE as unsigned.
425 define void @test_09(i32 %n) {
426 ; CHECK-LABEL: @test_09(
428 ; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 [[N:%.*]] to i64
429 ; CHECK-NEXT: br label [[LOOP:%.*]]
431 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
432 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
433 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ne i64 [[IV]], [[ZEXT]]
434 ; CHECK-NEXT: br i1 [[TMP0]], label [[LOOP]], label [[EXIT:%.*]]
436 ; CHECK-NEXT: ret void
441 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
442 %iv.next = add i64 %iv, 1
443 %narrow.iv = trunc i64 %iv to i32
444 %cmp = icmp ne i32 %narrow.iv, %n
445 br i1 %cmp, label %loop, label %exit
450 ; Widen NE as signed.
451 define void @test_10(i32 %n) {
452 ; CHECK-LABEL: @test_10(
454 ; CHECK-NEXT: [[SEXT:%.*]] = sext i32 [[N:%.*]] to i64
455 ; CHECK-NEXT: br label [[LOOP:%.*]]
457 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ -100, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
458 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
459 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ne i64 [[IV]], [[SEXT]]
460 ; CHECK-NEXT: [[NEGCMP:%.*]] = icmp slt i64 [[IV]], -10
461 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP0]], [[NEGCMP]]
462 ; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[EXIT:%.*]]
464 ; CHECK-NEXT: ret void
469 %iv = phi i64 [ -100, %entry ], [ %iv.next, %loop ]
470 %iv.next = add i64 %iv, 1
471 %narrow.iv = trunc i64 %iv to i32
472 %trunccmp = icmp ne i32 %narrow.iv, %n
473 %negcmp = icmp slt i64 %iv, -10
474 %cmp = and i1 %trunccmp, %negcmp
475 br i1 %cmp, label %loop, label %exit
480 define void @test_11() {
481 ; CHECK-LABEL: @test_11(
482 ; CHECK-NEXT: br label [[BB1:%.*]]
484 ; CHECK-NEXT: br i1 undef, label [[BB2:%.*]], label [[BB6:%.*]]
486 ; CHECK-NEXT: br i1 undef, label [[BB3:%.*]], label [[BB4:%.*]]
488 ; CHECK-NEXT: br label [[BB4]]
490 ; CHECK-NEXT: br label [[BB6]]
492 ; CHECK-NEXT: [[_TMP24:%.*]] = icmp slt i16 undef, 0
493 ; CHECK-NEXT: br i1 [[_TMP24]], label [[BB5:%.*]], label [[BB5]]
495 ; CHECK-NEXT: br i1 false, label [[BB1]], label [[BB7:%.*]]
497 ; CHECK-NEXT: ret void
501 bb1: ; preds = %bb6, %0
502 %e.5.0 = phi i32 [ 0, %0 ], [ %_tmp32, %bb6 ]
503 br i1 undef, label %bb2, label %bb6
506 %_tmp15 = trunc i32 %e.5.0 to i16
507 br i1 undef, label %bb3, label %bb4
512 bb4: ; preds = %bb3, %bb2
515 bb5: ; preds = %bb5, %bb5
516 %_tmp24 = icmp slt i16 %_tmp15, 0
517 br i1 %_tmp24, label %bb5, label %bb5
519 bb6: ; preds = %bb4, %bb1
520 %_tmp32 = add nuw nsw i32 %e.5.0, 1
521 br i1 false, label %bb1, label %bb7
527 ; Show that we can turn signed comparison to unsigned and use zext while
528 ; comparing non-negative values.
529 define void @test_12(i32* %p) {
530 ; CHECK-LABEL: @test_12(
532 ; CHECK-NEXT: [[N:%.*]] = load i32, i32* [[P:%.*]], !range !0
533 ; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 [[N]] to i64
534 ; CHECK-NEXT: br label [[LOOP:%.*]]
536 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
537 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
538 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i64 [[IV_NEXT]], [[ZEXT]]
539 ; CHECK-NEXT: br i1 [[TMP0]], label [[LOOP]], label [[EXIT:%.*]]
541 ; CHECK-NEXT: ret void
544 %n = load i32, i32* %p, !range !0
547 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
548 %iv.next = add i64 %iv, 1
549 %narrow.iv = trunc i64 %iv.next to i32
550 %cmp = icmp slt i32 %narrow.iv, %n
551 br i1 %cmp, label %loop, label %exit
556 define void @test_13a(i32 %n) {
558 ; CHECK-LABEL: @test_13a(
560 ; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 1024 to i64
561 ; CHECK-NEXT: br label [[LOOP:%.*]]
563 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
564 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 2
565 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ne i64 [[IV]], [[ZEXT]]
566 ; CHECK-NEXT: br i1 [[TMP0]], label [[LOOP]], label [[EXIT:%.*]]
568 ; CHECK-NEXT: ret void
573 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
574 %iv.next = add nsw nuw i64 %iv, 2
575 %narrow.iv = trunc i64 %iv to i32
576 %cmp = icmp ne i32 1024, %narrow.iv
577 br i1 %cmp, label %loop, label %exit
582 define void @test_13b(i32 %n) {
584 ; CHECK-LABEL: @test_13b(
586 ; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 1024 to i64
587 ; CHECK-NEXT: br label [[LOOP:%.*]]
589 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
590 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 2
591 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i64 [[IV]], [[ZEXT]]
592 ; CHECK-NEXT: br i1 [[TMP0]], label [[LOOP]], label [[EXIT:%.*]]
594 ; CHECK-NEXT: ret void
599 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
600 %iv.next = add nsw nuw i64 %iv, 2
601 %narrow.iv = trunc i64 %iv to i32
602 %cmp = icmp ugt i32 1024, %narrow.iv
603 br i1 %cmp, label %loop, label %exit
608 define void @test_13c(i32 %n) {
610 ; CHECK-LABEL: @test_13c(
612 ; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 1024 to i64
613 ; CHECK-NEXT: br label [[LOOP:%.*]]
615 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
616 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 2
617 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i64 [[IV]], [[ZEXT]]
618 ; CHECK-NEXT: br i1 [[TMP0]], label [[LOOP]], label [[EXIT:%.*]]
620 ; CHECK-NEXT: ret void
625 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
626 %iv.next = add nsw nuw i64 %iv, 2
627 %narrow.iv = trunc i64 %iv to i32
628 %cmp = icmp sgt i32 1024, %narrow.iv
629 br i1 %cmp, label %loop, label %exit
634 define void @test_13d(i32 %n) {
636 ; CHECK-LABEL: @test_13d(
638 ; CHECK-NEXT: [[SEXT:%.*]] = sext i32 1024 to i64
639 ; CHECK-NEXT: br label [[LOOP:%.*]]
641 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ -20, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
642 ; CHECK-NEXT: [[IV_NEXT]] = add nsw i64 [[IV]], 2
643 ; CHECK-NEXT: [[TMP0:%.*]] = icmp slt i64 [[IV]], [[SEXT]]
644 ; CHECK-NEXT: br i1 [[TMP0]], label [[LOOP]], label [[EXIT:%.*]]
646 ; CHECK-NEXT: ret void
651 %iv = phi i64 [ -20, %entry ], [ %iv.next, %loop ]
652 %iv.next = add nsw i64 %iv, 2
653 %narrow.iv = trunc i64 %iv to i32
654 %cmp = icmp sgt i32 1024, %narrow.iv
655 br i1 %cmp, label %loop, label %exit
660 !0 = !{i32 0, i32 1000}