1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
4 define i1 @test_second_and_condition_implied_by_first(i8 %x) {
5 ; CHECK-LABEL: @test_second_and_condition_implied_by_first(
7 ; CHECK-NEXT: [[C_1:%.*]] = icmp ugt i8 [[X:%.*]], 10
8 ; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i8 [[X]], 5
9 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[C_1]], [[T_1]]
10 ; CHECK-NEXT: br i1 [[AND]], label [[THEN:%.*]], label [[ELSE:%.*]]
12 ; CHECK-NEXT: ret i1 false
14 ; CHECK-NEXT: ret i1 true
17 %c.1 = icmp ugt i8 %x, 10
18 %t.1 = icmp ugt i8 %x, 5
19 %and = and i1 %c.1, %t.1
20 br i1 %and, label %then, label %else
29 define i1 @test_same_cond_for_and(i8 %x) {
30 ; CHECK-LABEL: @test_same_cond_for_and(
32 ; CHECK-NEXT: [[C_1:%.*]] = icmp ugt i8 [[X:%.*]], 10
33 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[C_1]], [[C_1]]
34 ; CHECK-NEXT: br i1 [[AND]], label [[THEN:%.*]], label [[ELSE:%.*]]
36 ; CHECK-NEXT: ret i1 false
38 ; CHECK-NEXT: ret i1 true
41 %c.1 = icmp ugt i8 %x, 10
42 %and = and i1 %c.1, %c.1
43 br i1 %and, label %then, label %else
52 define i1 @test_second_and_condition_not_implied_by_first(i8 %x) {
53 ; CHECK-LABEL: @test_second_and_condition_not_implied_by_first(
55 ; CHECK-NEXT: [[C_1:%.*]] = icmp ugt i8 [[X:%.*]], 10
56 ; CHECK-NEXT: [[C_2:%.*]] = icmp ugt i8 [[X]], 5
57 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[C_2]], [[C_1]]
58 ; CHECK-NEXT: br i1 [[AND]], label [[THEN:%.*]], label [[ELSE:%.*]]
60 ; CHECK-NEXT: ret i1 false
62 ; CHECK-NEXT: ret i1 true
65 %c.1 = icmp ugt i8 %x, 10
66 %c.2 = icmp ugt i8 %x, 5
67 %and = and i1 %c.2, %c.1
68 br i1 %and, label %then, label %else