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: [[C:%.*]] = and i1 [[A:%.*]], true
749 ; CHECK-NEXT: br label [[DISPATCH:%.*]]
751 ; CHECK-NEXT: br i1 [[A]], label [[TRUE:%.*]], label [[DISPATCH]]
753 ; CHECK-NEXT: ret i1 true
760 br i1 %a, label %true, label %dispatch
766 define i32 @test18(i8 %a) {
767 ; CHECK-LABEL: @test18(
769 ; CHECK-NEXT: [[B:%.*]] = zext i8 [[A:%.*]] to i32
770 ; CHECK-NEXT: br label [[DISPATCH:%.*]]
772 ; CHECK-NEXT: switch i8 [[A]], label [[DISPATCH]] [
773 ; CHECK-NEXT: i8 93, label [[TARGET93:%.*]]
774 ; CHECK-NEXT: i8 -111, label [[DISPATCH]]
777 ; CHECK-NEXT: ret i32 93
780 %b = zext i8 %a to i32
784 switch i8 %a, label %dispatch [
785 i8 93, label %target93
786 i8 -111, label %dispatch
793 define i8 @test19(i8 %a) {
794 ; CHECK-LABEL: @test19(
796 ; CHECK-NEXT: [[C:%.*]] = add i8 [[A:%.*]], 3
797 ; CHECK-NEXT: br label [[DISPATCH:%.*]]
799 ; CHECK-NEXT: switch i8 [[A]], label [[DISPATCH]] [
800 ; CHECK-NEXT: i8 93, label [[TARGET93:%.*]]
801 ; CHECK-NEXT: i8 -111, label [[DISPATCH]]
804 ; CHECK-NEXT: ret i8 96
811 switch i8 %a, label %dispatch [
812 i8 93, label %target93
813 i8 -111, label %dispatch
820 ; Negative test. Shouldn't be incorrectly optimized to "ret i1 false".
822 define i1 @test20(i64 %a) {
823 ; CHECK-LABEL: @test20(
825 ; CHECK-NEXT: [[B:%.*]] = and i64 [[A:%.*]], 7
826 ; CHECK-NEXT: br label [[DISPATCH:%.*]]
828 ; CHECK-NEXT: switch i64 [[A]], label [[DEFAULT:%.*]] [
829 ; CHECK-NEXT: i64 0, label [[EXIT2:%.*]]
830 ; CHECK-NEXT: i64 -2147483647, label [[EXIT2]]
833 ; CHECK-NEXT: [[C:%.*]] = icmp eq i64 [[B]], 0
834 ; CHECK-NEXT: br label [[EXIT:%.*]]
836 ; CHECK-NEXT: ret i1 [[C]]
838 ; CHECK-NEXT: ret i1 false
845 switch i64 %a, label %default [
847 i64 -2147483647, label %exit2
851 %c = icmp eq i64 %b, 0
861 define i1 @slt(i8 %a, i8 %b) {
864 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[A:%.*]], [[B:%.*]]
865 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
866 ; CHECK-NEXT: ret i1 true
869 %cmp = icmp slt i8 %a, %b
870 call void @llvm.assume(i1 %cmp)
871 %res = icmp slt i8 %a, 127
875 define i1 @sgt(i8 %a, i8 %b) {
878 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[A:%.*]], [[B:%.*]]
879 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
880 ; CHECK-NEXT: ret i1 true
883 %cmp = icmp sgt i8 %a, %b
884 call void @llvm.assume(i1 %cmp)
885 %res = icmp sgt i8 %a, -128
889 define i1 @ult(i8 %a, i8 %b) {
892 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[A:%.*]], [[B:%.*]]
893 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
894 ; CHECK-NEXT: ret i1 true
897 %cmp = icmp ult i8 %a, %b
898 call void @llvm.assume(i1 %cmp)
899 %res = icmp ult i8 %a, 255
903 define i1 @ugt(i8 %a, i8 %b) {
906 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[A:%.*]], [[B:%.*]]
907 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
908 ; CHECK-NEXT: ret i1 true
911 %cmp = icmp ugt i8 %a, %b
912 call void @llvm.assume(i1 %cmp)
913 %res = icmp ugt i8 %a, 0
917 declare void @llvm.assume(i1)