1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -correlated-propagation -S < %s | FileCheck %s
6 define i32 @test1(i32 %a) nounwind {
8 ; CHECK-NEXT: [[A_OFF:%.*]] = add i32 [[A:%.*]], -8
9 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[A_OFF]], 8
10 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
12 ; CHECK-NEXT: br i1 false, label [[END:%.*]], label [[ELSE]]
14 ; CHECK-NEXT: ret i32 1
16 ; CHECK-NEXT: ret i32 2
18 %a.off = add i32 %a, -8
19 %cmp = icmp ult i32 %a.off, 8
20 br i1 %cmp, label %then, label %else
23 %dead = icmp eq i32 %a, 7
24 br i1 %dead, label %end, label %else
33 define i32 @test2(i32 %a) nounwind {
34 ; CHECK-LABEL: @test2(
35 ; CHECK-NEXT: [[A_OFF:%.*]] = add i32 [[A:%.*]], -8
36 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[A_OFF]], 8
37 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
39 ; CHECK-NEXT: br i1 false, label [[END:%.*]], label [[ELSE]]
41 ; CHECK-NEXT: ret i32 1
43 ; CHECK-NEXT: ret i32 2
45 %a.off = add i32 %a, -8
46 %cmp = icmp ult i32 %a.off, 8
47 br i1 %cmp, label %then, label %else
50 %dead = icmp ugt i32 %a, 15
51 br i1 %dead, label %end, label %else
60 define i32 @test3(i32 %c) nounwind {
61 ; CHECK-LABEL: @test3(
62 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[C:%.*]], 2
63 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
65 ; CHECK-NEXT: ret i32 1
67 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[C]], 3
68 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_THEN2:%.*]], label [[IF_END8:%.*]]
70 ; CHECK-NEXT: br i1 true, label [[IF_THEN4:%.*]], label [[IF_END6:%.*]]
72 ; CHECK-NEXT: ret i32 2
74 ; CHECK-NEXT: ret i32 3
76 ; CHECK-NEXT: ret i32 4
78 %cmp = icmp slt i32 %c, 2
79 br i1 %cmp, label %if.then, label %if.end
85 %cmp1 = icmp slt i32 %c, 3
86 br i1 %cmp1, label %if.then2, label %if.end8
89 %cmp2 = icmp eq i32 %c, 2
90 br i1 %cmp2, label %if.then4, label %if.end6
102 define i32 @test4(i32 %c) nounwind {
103 ; CHECK-LABEL: @test4(
104 ; CHECK-NEXT: switch i32 [[C:%.*]], label [[SW_DEFAULT:%.*]] [
105 ; CHECK-NEXT: i32 1, label [[SW_BB:%.*]]
106 ; CHECK-NEXT: i32 2, label [[SW_BB]]
107 ; CHECK-NEXT: i32 4, label [[SW_BB]]
110 ; CHECK-NEXT: br i1 true, label [[IF_THEN:%.*]], label [[IF_END:%.*]]
112 ; CHECK-NEXT: br label [[RETURN:%.*]]
114 ; CHECK-NEXT: br label [[RETURN]]
116 ; CHECK-NEXT: br label [[RETURN]]
118 ; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i32 [ 42, [[SW_DEFAULT]] ], [ 4, [[IF_THEN]] ], [ 9, [[IF_END]] ]
119 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
121 switch i32 %c, label %sw.default [
128 %cmp = icmp sge i32 %c, 1
129 br i1 %cmp, label %if.then, label %if.end
141 %retval.0 = phi i32 [ 42, %sw.default ], [ 4, %if.then ], [ 9, %if.end ]
145 define i1 @test5(i32 %c) nounwind {
146 ; CHECK-LABEL: @test5(
147 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[C:%.*]], 5
148 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
150 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[C]], 4
151 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_END]], label [[IF_END8:%.*]]
153 ; CHECK-NEXT: ret i1 true
155 ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 [[C]], 3
156 ; CHECK-NEXT: [[OR:%.*]] = or i1 false, false
157 ; CHECK-NEXT: ret i1 [[CMP2]]
159 %cmp = icmp slt i32 %c, 5
160 br i1 %cmp, label %if.then, label %if.end
163 %cmp1 = icmp eq i32 %c, 4
164 br i1 %cmp1, label %if.end, label %if.end8
170 %cmp2 = icmp eq i32 %c, 3
171 %cmp3 = icmp eq i32 %c, 4
172 %cmp4 = icmp eq i32 %c, 6
173 %or = or i1 %cmp3, %cmp4
177 define i1 @test6(i32 %c) nounwind {
178 ; CHECK-LABEL: @test6(
179 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i32 [[C:%.*]], 7
180 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
182 ; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[C]], 6
183 ; CHECK-NEXT: br i1 [[COND]], label [[SW_BB:%.*]], label [[IF_END]]
185 ; CHECK-NEXT: ret i1 true
187 ; CHECK-NEXT: ret i1 true
189 %cmp = icmp ule i32 %c, 7
190 br i1 %cmp, label %if.then, label %if.end
193 switch i32 %c, label %if.end [
202 %cmp2 = icmp eq i32 %c, 6
206 define i1 @test7(i32 %c) nounwind {
207 ; CHECK-LABEL: @test7(
209 ; CHECK-NEXT: switch i32 [[C:%.*]], label [[SW_DEFAULT:%.*]] [
210 ; CHECK-NEXT: i32 6, label [[SW_BB:%.*]]
211 ; CHECK-NEXT: i32 7, label [[SW_BB]]
214 ; CHECK-NEXT: ret i1 true
216 ; CHECK-NEXT: [[CMP5:%.*]] = icmp eq i32 [[C]], 5
217 ; CHECK-NEXT: [[CMP8:%.*]] = icmp eq i32 [[C]], 8
218 ; CHECK-NEXT: [[OR:%.*]] = or i1 [[CMP5]], false
219 ; CHECK-NEXT: [[OR2:%.*]] = or i1 false, [[CMP8]]
220 ; CHECK-NEXT: ret i1 false
223 switch i32 %c, label %sw.default [
232 %cmp5 = icmp eq i32 %c, 5
233 %cmp6 = icmp eq i32 %c, 6
234 %cmp7 = icmp eq i32 %c, 7
235 %cmp8 = icmp eq i32 %c, 8
236 %or = or i1 %cmp5, %cmp6
237 %or2 = or i1 %cmp7, %cmp8
241 define i1 @test8(i64* %p) {
242 ; CHECK-LABEL: @test8(
243 ; CHECK-NEXT: [[A:%.*]] = load i64, i64* [[P:%.*]], !range !0
244 ; CHECK-NEXT: [[RES:%.*]] = icmp eq i64 [[A]], 0
245 ; CHECK-NEXT: ret i1 false
247 %a = load i64, i64* %p, !range !{i64 4, i64 255}
248 %res = icmp eq i64 %a, 0
252 define i1 @test9(i64* %p) {
253 ; CHECK-LABEL: @test9(
254 ; CHECK-NEXT: [[A:%.*]] = load i64, i64* [[P:%.*]], !range !1
255 ; CHECK-NEXT: [[RES:%.*]] = icmp eq i64 [[A]], 0
256 ; CHECK-NEXT: ret i1 true
258 %a = load i64, i64* %p, !range !{i64 0, i64 1}
259 %res = icmp eq i64 %a, 0
263 define i1 @test10(i64* %p) {
264 ; CHECK-LABEL: @test10(
265 ; CHECK-NEXT: [[A:%.*]] = load i64, i64* [[P:%.*]], !range !2
266 ; CHECK-NEXT: [[RES:%.*]] = icmp eq i64 [[A]], 0
267 ; CHECK-NEXT: ret i1 false
269 %a = load i64, i64* %p, !range !{i64 4, i64 8, i64 15, i64 20}
270 %res = icmp eq i64 %a, 0
274 @g = external global i32
276 define i1 @test11() {
277 ; CHECK-LABEL: @test11(
278 ; CHECK-NEXT: [[POSITIVE:%.*]] = load i32, i32* @g, !range !3
279 ; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[POSITIVE]], 1
280 ; CHECK-NEXT: [[TEST:%.*]] = icmp sgt i32 [[ADD]], 0
281 ; CHECK-NEXT: br label [[NEXT:%.*]]
283 ; CHECK-NEXT: ret i1 true
285 %positive = load i32, i32* @g, !range !{i32 1, i32 2048}
286 %add = add i32 %positive, 1
287 %test = icmp sgt i32 %add, 0
294 define i32 @test12(i32 %a, i32 %b) {
295 ; CHECK-LABEL: @test12(
296 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[A:%.*]], [[B:%.*]]
297 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
299 ; CHECK-NEXT: br i1 false, label [[END:%.*]], label [[ELSE]]
301 ; CHECK-NEXT: ret i32 1
303 ; CHECK-NEXT: ret i32 2
305 %cmp = icmp ult i32 %a, %b
306 br i1 %cmp, label %then, label %else
309 %dead = icmp eq i32 %a, -1
310 br i1 %dead, label %end, label %else
319 define i32 @test12_swap(i32 %a, i32 %b) {
320 ; CHECK-LABEL: @test12_swap(
321 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i32 [[B:%.*]], [[A:%.*]]
322 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
324 ; CHECK-NEXT: br i1 false, label [[END:%.*]], label [[ELSE]]
326 ; CHECK-NEXT: ret i32 1
328 ; CHECK-NEXT: ret i32 2
330 %cmp = icmp ugt i32 %b, %a
331 br i1 %cmp, label %then, label %else
334 %dead = icmp eq i32 %a, -1
335 br i1 %dead, label %end, label %else
344 ; The same as @test12 but the second check is on the false path
346 define i32 @test12_neg(i32 %a, i32 %b) {
347 ; CHECK-LABEL: @test12_neg(
348 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[A:%.*]], [[B:%.*]]
349 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
351 ; CHECK-NEXT: [[ALIVE:%.*]] = icmp eq i32 [[A]], -1
352 ; CHECK-NEXT: br i1 [[ALIVE]], label [[END:%.*]], label [[THEN]]
354 ; CHECK-NEXT: ret i32 1
356 ; CHECK-NEXT: ret i32 2
358 %cmp = icmp ult i32 %a, %b
359 br i1 %cmp, label %then, label %else
362 %alive = icmp eq i32 %a, -1
363 br i1 %alive, label %end, label %then
372 ; The same as @test12 but with signed comparison
374 define i32 @test12_signed(i32 %a, i32 %b) {
375 ; CHECK-LABEL: @test12_signed(
376 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[A:%.*]], [[B:%.*]]
377 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
379 ; CHECK-NEXT: br i1 false, label [[END:%.*]], label [[ELSE]]
381 ; CHECK-NEXT: ret i32 1
383 ; CHECK-NEXT: ret i32 2
385 %cmp = icmp slt i32 %a, %b
386 br i1 %cmp, label %then, label %else
389 %dead = icmp eq i32 %a, 2147483647
390 br i1 %dead, label %end, label %else
399 define i32 @test13(i32 %a, i32 %b) {
400 ; CHECK-LABEL: @test13(
401 ; CHECK-NEXT: [[A_OFF:%.*]] = add i32 [[A:%.*]], -8
402 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[A_OFF]], [[B:%.*]]
403 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
405 ; CHECK-NEXT: br i1 false, label [[END:%.*]], label [[ELSE]]
407 ; CHECK-NEXT: ret i32 1
409 ; CHECK-NEXT: ret i32 2
411 %a.off = add i32 %a, -8
412 %cmp = icmp ult i32 %a.off, %b
413 br i1 %cmp, label %then, label %else
416 %dead = icmp eq i32 %a, 7
417 br i1 %dead, label %end, label %else
426 define i32 @test13_swap(i32 %a, i32 %b) {
427 ; CHECK-LABEL: @test13_swap(
428 ; CHECK-NEXT: [[A_OFF:%.*]] = add i32 [[A:%.*]], -8
429 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i32 [[B:%.*]], [[A_OFF]]
430 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
432 ; CHECK-NEXT: br i1 false, label [[END:%.*]], label [[ELSE]]
434 ; CHECK-NEXT: ret i32 1
436 ; CHECK-NEXT: ret i32 2
438 %a.off = add i32 %a, -8
439 %cmp = icmp ugt i32 %b, %a.off
440 br i1 %cmp, label %then, label %else
443 %dead = icmp eq i32 %a, 7
444 br i1 %dead, label %end, label %else
453 define i1 @test14_slt(i32 %a) {
454 ; CHECK-LABEL: @test14_slt(
455 ; CHECK-NEXT: [[A_OFF:%.*]] = add i32 [[A:%.*]], -8
456 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[A_OFF]], 8
457 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
459 ; CHECK-NEXT: [[RESULT:%.*]] = or i1 false, false
460 ; CHECK-NEXT: ret i1 [[RESULT]]
462 ; CHECK-NEXT: ret i1 false
464 %a.off = add i32 %a, -8
465 %cmp = icmp slt i32 %a.off, 8
466 br i1 %cmp, label %then, label %else
469 %dead.1 = icmp eq i32 %a, -2147483641
470 %dead.2 = icmp eq i32 %a, 16
471 %result = or i1 %dead.1, %dead.2
478 define i1 @test14_sle(i32 %a) {
479 ; CHECK-LABEL: @test14_sle(
480 ; CHECK-NEXT: [[A_OFF:%.*]] = add i32 [[A:%.*]], -8
481 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i32 [[A_OFF]], 8
482 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
484 ; CHECK-NEXT: [[ALIVE:%.*]] = icmp eq i32 [[A]], 16
485 ; CHECK-NEXT: [[RESULT:%.*]] = or i1 false, [[ALIVE]]
486 ; CHECK-NEXT: ret i1 [[RESULT]]
488 ; CHECK-NEXT: ret i1 false
490 %a.off = add i32 %a, -8
491 %cmp = icmp sle i32 %a.off, 8
492 br i1 %cmp, label %then, label %else
495 %dead = icmp eq i32 %a, -2147483641
496 %alive = icmp eq i32 %a, 16
497 %result = or i1 %dead, %alive
504 define i1 @test14_sgt(i32 %a) {
505 ; CHECK-LABEL: @test14_sgt(
506 ; CHECK-NEXT: [[A_OFF:%.*]] = add i32 [[A:%.*]], -8
507 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[A_OFF]], 8
508 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
510 ; CHECK-NEXT: [[RESULT:%.*]] = or i1 false, false
511 ; CHECK-NEXT: ret i1 [[RESULT]]
513 ; CHECK-NEXT: ret i1 false
515 %a.off = add i32 %a, -8
516 %cmp = icmp sgt i32 %a.off, 8
517 br i1 %cmp, label %then, label %else
520 %dead.1 = icmp eq i32 %a, -2147483640
521 %dead.2 = icmp eq i32 %a, 16
522 %result = or i1 %dead.1, %dead.2
529 define i1 @test14_sge(i32 %a) {
530 ; CHECK-LABEL: @test14_sge(
531 ; CHECK-NEXT: [[A_OFF:%.*]] = add i32 [[A:%.*]], -8
532 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i32 [[A_OFF]], 8
533 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
535 ; CHECK-NEXT: [[ALIVE:%.*]] = icmp eq i32 [[A]], 16
536 ; CHECK-NEXT: [[RESULT:%.*]] = or i1 false, [[ALIVE]]
537 ; CHECK-NEXT: ret i1 [[RESULT]]
539 ; CHECK-NEXT: ret i1 false
541 %a.off = add i32 %a, -8
542 %cmp = icmp sge i32 %a.off, 8
543 br i1 %cmp, label %then, label %else
546 %dead = icmp eq i32 %a, -2147483640
547 %alive = icmp eq i32 %a, 16
548 %result = or i1 %dead, %alive
555 define i1 @test14_ule(i32 %a) {
556 ; CHECK-LABEL: @test14_ule(
557 ; CHECK-NEXT: [[A_OFF:%.*]] = add i32 [[A:%.*]], -8
558 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i32 [[A_OFF]], 8
559 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
561 ; CHECK-NEXT: [[ALIVE:%.*]] = icmp eq i32 [[A]], 16
562 ; CHECK-NEXT: [[RESULT:%.*]] = or i1 false, [[ALIVE]]
563 ; CHECK-NEXT: ret i1 [[RESULT]]
565 ; CHECK-NEXT: ret i1 false
567 %a.off = add i32 %a, -8
568 %cmp = icmp ule i32 %a.off, 8
569 br i1 %cmp, label %then, label %else
572 %dead = icmp eq i32 %a, 7
573 %alive = icmp eq i32 %a, 16
574 %result = or i1 %dead, %alive
581 define i1 @test14_ugt(i32 %a) {
582 ; CHECK-LABEL: @test14_ugt(
583 ; CHECK-NEXT: [[A_OFF:%.*]] = add i32 [[A:%.*]], -8
584 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i32 [[A_OFF]], 8
585 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
587 ; CHECK-NEXT: [[RESULT:%.*]] = or i1 false, false
588 ; CHECK-NEXT: ret i1 [[RESULT]]
590 ; CHECK-NEXT: ret i1 false
592 %a.off = add i32 %a, -8
593 %cmp = icmp ugt i32 %a.off, 8
594 br i1 %cmp, label %then, label %else
597 %dead.1 = icmp eq i32 %a, 8
598 %dead.2 = icmp eq i32 %a, 16
599 %result = or i1 %dead.1, %dead.2
606 define i1 @test14_uge(i32 %a) {
607 ; CHECK-LABEL: @test14_uge(
608 ; CHECK-NEXT: [[A_OFF:%.*]] = add i32 [[A:%.*]], -8
609 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i32 [[A_OFF]], 8
610 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
612 ; CHECK-NEXT: [[ALIVE:%.*]] = icmp eq i32 [[A]], 16
613 ; CHECK-NEXT: [[RESULT:%.*]] = or i1 false, [[ALIVE]]
614 ; CHECK-NEXT: ret i1 [[RESULT]]
616 ; CHECK-NEXT: ret i1 false
618 %a.off = add i32 %a, -8
619 %cmp = icmp uge i32 %a.off, 8
620 br i1 %cmp, label %then, label %else
623 %dead = icmp eq i32 %a, 8
624 %alive = icmp eq i32 %a, 16
625 %result = or i1 %dead, %alive
632 @limit = external global i32
633 define i1 @test15(i32 %a) {
634 ; CHECK-LABEL: @test15(
635 ; CHECK-NEXT: [[LIMIT:%.*]] = load i32, i32* @limit, !range !4
636 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[A:%.*]], [[LIMIT]]
637 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
639 ; CHECK-NEXT: ret i1 false
641 ; CHECK-NEXT: ret i1 false
643 %limit = load i32, i32* @limit, !range !{i32 0, i32 256}
644 %cmp = icmp ult i32 %a, %limit
645 br i1 %cmp, label %then, label %else
648 %result = icmp eq i32 %a, 255
655 define i32 @test16(i8 %a) {
656 ; CHECK-LABEL: @test16(
658 ; CHECK-NEXT: [[B:%.*]] = zext i8 [[A:%.*]] to i32
659 ; CHECK-NEXT: br label [[DISPATCH:%.*]]
661 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[A]], 93
662 ; CHECK-NEXT: br i1 [[CMP]], label [[TARGET93:%.*]], label [[DISPATCH]]
664 ; CHECK-NEXT: ret i32 93
667 %b = zext i8 %a to i32
671 %cmp = icmp eq i8 %a, 93
672 br i1 %cmp, label %target93, label %dispatch
678 define i32 @test16_i1(i1 %a) {
679 ; CHECK-LABEL: @test16_i1(
681 ; CHECK-NEXT: [[B:%.*]] = zext i1 [[A:%.*]] to i32
682 ; CHECK-NEXT: br label [[DISPATCH:%.*]]
684 ; CHECK-NEXT: br i1 [[A]], label [[TRUE:%.*]], label [[DISPATCH]]
686 ; CHECK-NEXT: ret i32 1
689 %b = zext i1 %a to i32
693 br i1 %a, label %true, label %dispatch
699 define i8 @test17(i8 %a) {
700 ; CHECK-LABEL: @test17(
702 ; CHECK-NEXT: [[C:%.*]] = add i8 [[A:%.*]], 3
703 ; CHECK-NEXT: br label [[DISPATCH:%.*]]
705 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[A]], 93
706 ; CHECK-NEXT: br i1 [[CMP]], label [[TARGET93:%.*]], label [[DISPATCH]]
708 ; CHECK-NEXT: ret i8 96
715 %cmp = icmp eq i8 %a, 93
716 br i1 %cmp, label %target93, label %dispatch
722 define i8 @test17_2(i8 %a) {
723 ; CHECK-LABEL: @test17_2(
725 ; CHECK-NEXT: [[C:%.*]] = add i8 [[A:%.*]], [[A]]
726 ; CHECK-NEXT: br label [[DISPATCH:%.*]]
728 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[A]], 93
729 ; CHECK-NEXT: br i1 [[CMP]], label [[TARGET93:%.*]], label [[DISPATCH]]
731 ; CHECK-NEXT: ret i8 -70
738 %cmp = icmp eq i8 %a, 93
739 br i1 %cmp, label %target93, label %dispatch
745 define i1 @test17_i1(i1 %a) {
746 ; CHECK-LABEL: @test17_i1(
748 ; CHECK-NEXT: br label [[DISPATCH:%.*]]
750 ; CHECK-NEXT: br i1 [[A:%.*]], label [[TRUE:%.*]], label [[DISPATCH]]
752 ; CHECK-NEXT: ret i1 true
759 br i1 %a, label %true, label %dispatch
765 define i32 @test18(i8 %a) {
766 ; CHECK-LABEL: @test18(
768 ; CHECK-NEXT: [[B:%.*]] = zext i8 [[A:%.*]] to i32
769 ; CHECK-NEXT: br label [[DISPATCH:%.*]]
771 ; CHECK-NEXT: switch i8 [[A]], label [[DISPATCH]] [
772 ; CHECK-NEXT: i8 93, label [[TARGET93:%.*]]
773 ; CHECK-NEXT: i8 -111, label [[DISPATCH]]
776 ; CHECK-NEXT: ret i32 93
779 %b = zext i8 %a to i32
783 switch i8 %a, label %dispatch [
784 i8 93, label %target93
785 i8 -111, label %dispatch
792 define i8 @test19(i8 %a) {
793 ; CHECK-LABEL: @test19(
795 ; CHECK-NEXT: [[C:%.*]] = add i8 [[A:%.*]], 3
796 ; CHECK-NEXT: br label [[DISPATCH:%.*]]
798 ; CHECK-NEXT: switch i8 [[A]], label [[DISPATCH]] [
799 ; CHECK-NEXT: i8 93, label [[TARGET93:%.*]]
800 ; CHECK-NEXT: i8 -111, label [[DISPATCH]]
803 ; CHECK-NEXT: ret i8 96
810 switch i8 %a, label %dispatch [
811 i8 93, label %target93
812 i8 -111, label %dispatch
819 ; Negative test. Shouldn't be incorrectly optimized to "ret i1 false".
821 define i1 @test20(i64 %a) {
822 ; CHECK-LABEL: @test20(
824 ; CHECK-NEXT: [[B:%.*]] = and i64 [[A:%.*]], 7
825 ; CHECK-NEXT: br label [[DISPATCH:%.*]]
827 ; CHECK-NEXT: switch i64 [[A]], label [[DEFAULT:%.*]] [
828 ; CHECK-NEXT: i64 0, label [[EXIT2:%.*]]
829 ; CHECK-NEXT: i64 -2147483647, label [[EXIT2]]
832 ; CHECK-NEXT: [[C:%.*]] = icmp eq i64 [[B]], 0
833 ; CHECK-NEXT: br label [[EXIT:%.*]]
835 ; CHECK-NEXT: ret i1 [[C]]
837 ; CHECK-NEXT: ret i1 false
844 switch i64 %a, label %default [
846 i64 -2147483647, label %exit2
850 %c = icmp eq i64 %b, 0
860 define i1 @slt(i8 %a, i8 %b) {
863 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[A:%.*]], [[B:%.*]]
864 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
865 ; CHECK-NEXT: ret i1 true
868 %cmp = icmp slt i8 %a, %b
869 call void @llvm.assume(i1 %cmp)
870 %res = icmp slt i8 %a, 127
874 define i1 @sgt(i8 %a, i8 %b) {
877 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[A:%.*]], [[B:%.*]]
878 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
879 ; CHECK-NEXT: ret i1 true
882 %cmp = icmp sgt i8 %a, %b
883 call void @llvm.assume(i1 %cmp)
884 %res = icmp sgt i8 %a, -128
888 define i1 @ult(i8 %a, i8 %b) {
891 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[A:%.*]], [[B:%.*]]
892 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
893 ; CHECK-NEXT: ret i1 true
896 %cmp = icmp ult i8 %a, %b
897 call void @llvm.assume(i1 %cmp)
898 %res = icmp ult i8 %a, 255
902 define i1 @ugt(i8 %a, i8 %b) {
905 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[A:%.*]], [[B:%.*]]
906 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
907 ; CHECK-NEXT: ret i1 true
910 %cmp = icmp ugt i8 %a, %b
911 call void @llvm.assume(i1 %cmp)
912 %res = icmp ugt i8 %a, 0
916 declare void @llvm.assume(i1)