|
26 | 26 | ret i1 1
|
27 | 27 | }
|
28 | 28 |
|
| 29 | +define i1 @test_first_and_condition_implied_by_second_ops(i8 %x) { |
| 30 | +; CHECK-LABEL: @test_first_and_condition_implied_by_second_ops( |
| 31 | +; CHECK-NEXT: entry: |
| 32 | +; CHECK-NEXT: [[C_1:%.*]] = icmp ugt i8 [[X:%.*]], 10 |
| 33 | +; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i8 [[X]], 5 |
| 34 | +; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[C_1]] |
| 35 | +; CHECK-NEXT: br i1 [[AND]], label [[THEN:%.*]], label [[ELSE:%.*]] |
| 36 | +; CHECK: then: |
| 37 | +; CHECK-NEXT: ret i1 false |
| 38 | +; CHECK: else: |
| 39 | +; CHECK-NEXT: ret i1 true |
| 40 | +; |
| 41 | +entry: |
| 42 | + %c.1 = icmp ugt i8 %x, 10 |
| 43 | + %t.1 = icmp ugt i8 %x, 5 |
| 44 | + %and = and i1 %t.1, %c.1 |
| 45 | + br i1 %and, label %then, label %else |
| 46 | + |
| 47 | +then: |
| 48 | + ret i1 0 |
| 49 | + |
| 50 | +else: |
| 51 | + ret i1 1 |
| 52 | +} |
| 53 | + |
29 | 54 | define i1 @test_second_and_condition_implied_by_first_select_form(i8 %x) {
|
30 | 55 | ; CHECK-LABEL: @test_second_and_condition_implied_by_first_select_form(
|
31 | 56 | ; CHECK-NEXT: entry:
|
|
51 | 76 | ret i1 1
|
52 | 77 | }
|
53 | 78 |
|
| 79 | +define i1 @test_first_and_condition_implied_by_second_select_form(i8 %x) { |
| 80 | +; CHECK-LABEL: @test_first_and_condition_implied_by_second_select_form( |
| 81 | +; CHECK-NEXT: entry: |
| 82 | +; CHECK-NEXT: [[C_1:%.*]] = icmp ugt i8 [[X:%.*]], 10 |
| 83 | +; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i8 [[X]], 5 |
| 84 | +; CHECK-NEXT: [[AND:%.*]] = select i1 [[T_1]], i1 [[C_1]], i1 false |
| 85 | +; CHECK-NEXT: br i1 [[AND]], label [[THEN:%.*]], label [[ELSE:%.*]] |
| 86 | +; CHECK: then: |
| 87 | +; CHECK-NEXT: ret i1 false |
| 88 | +; CHECK: else: |
| 89 | +; CHECK-NEXT: ret i1 true |
| 90 | +; |
| 91 | +entry: |
| 92 | + %c.1 = icmp ugt i8 %x, 10 |
| 93 | + %t.1 = icmp ugt i8 %x, 5 |
| 94 | + %and = select i1 %t.1, i1 %c.1, i1 false |
| 95 | + br i1 %and, label %then, label %else |
| 96 | + |
| 97 | +then: |
| 98 | + ret i1 0 |
| 99 | + |
| 100 | +else: |
| 101 | + ret i1 1 |
| 102 | +} |
| 103 | + |
54 | 104 | define i1 @test_same_cond_for_and(i8 %x) {
|
55 | 105 | ; CHECK-LABEL: @test_same_cond_for_and(
|
56 | 106 | ; CHECK-NEXT: entry:
|
@@ -394,3 +444,37 @@ then:
|
394 | 444 | else:
|
395 | 445 | ret i1 %t.1
|
396 | 446 | }
|
| 447 | + |
| 448 | +define i1 @and_select_first_implies_second_may_be_poison(ptr noundef %A, ptr noundef %B) { |
| 449 | +; CHECK-LABEL: @and_select_first_implies_second_may_be_poison( |
| 450 | +; CHECK-NEXT: entry: |
| 451 | +; CHECK-NEXT: [[C_1:%.*]] = icmp ne ptr [[A:%.*]], [[B:%.*]] |
| 452 | +; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds ptr, ptr [[B]], i64 -1 |
| 453 | +; CHECK-NEXT: [[C_2:%.*]] = icmp ugt ptr [[GEP]], [[A]] |
| 454 | +; CHECK-NEXT: [[AND:%.*]] = select i1 [[C_2]], i1 true, i1 false |
| 455 | +; CHECK-NEXT: ret i1 [[AND]] |
| 456 | +; |
| 457 | +entry: |
| 458 | + %c.1 = icmp ne ptr %A, %B |
| 459 | + %gep = getelementptr inbounds ptr, ptr %B, i64 -1 |
| 460 | + %c.2 = icmp ugt ptr %gep, %A |
| 461 | + %and = select i1 %c.2, i1 %c.1, i1 false |
| 462 | + ret i1 %and |
| 463 | +} |
| 464 | + |
| 465 | +define i1 @and_select_second_implies_first_may_be_poison(ptr noundef %A, ptr noundef %B) { |
| 466 | +; CHECK-LABEL: @and_select_second_implies_first_may_be_poison( |
| 467 | +; CHECK-NEXT: entry: |
| 468 | +; CHECK-NEXT: [[C_1:%.*]] = icmp ne ptr [[A:%.*]], [[B:%.*]] |
| 469 | +; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds ptr, ptr [[B]], i64 -1 |
| 470 | +; CHECK-NEXT: [[C_2:%.*]] = icmp ugt ptr [[GEP]], [[A]] |
| 471 | +; CHECK-NEXT: [[AND:%.*]] = select i1 [[C_1]], i1 [[C_2]], i1 false |
| 472 | +; CHECK-NEXT: ret i1 [[AND]] |
| 473 | +; |
| 474 | +entry: |
| 475 | + %c.1 = icmp ne ptr %A, %B |
| 476 | + %gep = getelementptr inbounds ptr, ptr %B, i64 -1 |
| 477 | + %c.2 = icmp ugt ptr %gep, %A |
| 478 | + %and = select i1 %c.1, i1 %c.2, i1 false |
| 479 | + ret i1 %and |
| 480 | +} |
0 commit comments