1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -constraint-elimination -S %s | FileCheck %s
6 define i32 @test_and_ule(i32 %x, i32 %y, i32 %z, i32 %a) {
7 ; CHECK-LABEL: @test_and_ule(
9 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], [[Y:%.*]]
10 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[Y]], [[Z:%.*]]
11 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[C_1]], [[C_2]]
12 ; CHECK-NEXT: br i1 [[AND]], label [[BB1:%.*]], label [[EXIT:%.*]]
14 ; CHECK-NEXT: [[T_1:%.*]] = icmp ule i32 [[X]], [[Z]]
15 ; CHECK-NEXT: call void @use(i1 true)
16 ; CHECK-NEXT: [[T_2:%.*]] = icmp ule i32 [[X]], [[Y]]
17 ; CHECK-NEXT: call void @use(i1 true)
18 ; CHECK-NEXT: [[T_3:%.*]] = icmp ule i32 [[Y]], [[Z]]
19 ; CHECK-NEXT: call void @use(i1 true)
20 ; CHECK-NEXT: [[C_3:%.*]] = icmp ule i32 [[X]], [[A:%.*]]
21 ; CHECK-NEXT: call void @use(i1 [[C_3]])
22 ; CHECK-NEXT: ret i32 10
24 ; CHECK-NEXT: [[C_4:%.*]] = icmp ule i32 [[X]], [[Z]]
25 ; CHECK-NEXT: call void @use(i1 [[C_4]])
26 ; CHECK-NEXT: [[C_5:%.*]] = icmp ule i32 [[X]], [[A]]
27 ; CHECK-NEXT: call void @use(i1 [[C_5]])
28 ; CHECK-NEXT: [[C_6:%.*]] = icmp ule i32 [[X]], [[Y]]
29 ; CHECK-NEXT: call void @use(i1 [[C_6]])
30 ; CHECK-NEXT: [[C_7:%.*]] = icmp ule i32 [[Y]], [[Z]]
31 ; CHECK-NEXT: call void @use(i1 [[C_7]])
32 ; CHECK-NEXT: ret i32 20
35 %c.1 = icmp ule i32 %x, %y
36 %c.2 = icmp ule i32 %y, %z
37 %and = and i1 %c.1, %c.2
38 br i1 %and, label %bb1, label %exit
41 %t.1 = icmp ule i32 %x, %z
42 call void @use(i1 %t.1)
44 %t.2 = icmp ule i32 %x, %y
45 call void @use(i1 %t.2)
47 %t.3 = icmp ule i32 %y, %z
48 call void @use(i1 %t.3)
51 %c.3 = icmp ule i32 %x, %a
52 call void @use(i1 %c.3)
57 %c.4 = icmp ule i32 %x, %z
58 call void @use(i1 %c.4)
60 %c.5 = icmp ule i32 %x, %a
61 call void @use(i1 %c.5)
63 %c.6 = icmp ule i32 %x, %y
64 call void @use(i1 %c.6)
66 %c.7 = icmp ule i32 %y, %z
67 call void @use(i1 %c.7)
72 ; The result of test_and_ule and test_and_select_ule should be same
73 define i32 @test_and_select_ule(i32 %x, i32 %y, i32 %z, i32 %a) {
74 ; CHECK-LABEL: @test_and_select_ule(
76 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], [[Y:%.*]]
77 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[Y]], [[Z:%.*]]
78 ; CHECK-NEXT: [[AND:%.*]] = select i1 [[C_1]], i1 [[C_2]], i1 false
79 ; CHECK-NEXT: br i1 [[AND]], label [[BB1:%.*]], label [[EXIT:%.*]]
81 ; CHECK-NEXT: [[T_1:%.*]] = icmp ule i32 [[X]], [[Z]]
82 ; CHECK-NEXT: call void @use(i1 true)
83 ; CHECK-NEXT: [[T_2:%.*]] = icmp ule i32 [[X]], [[Y]]
84 ; CHECK-NEXT: call void @use(i1 true)
85 ; CHECK-NEXT: [[T_3:%.*]] = icmp ule i32 [[Y]], [[Z]]
86 ; CHECK-NEXT: call void @use(i1 true)
87 ; CHECK-NEXT: [[C_3:%.*]] = icmp ule i32 [[X]], [[A:%.*]]
88 ; CHECK-NEXT: call void @use(i1 [[C_3]])
89 ; CHECK-NEXT: ret i32 10
91 ; CHECK-NEXT: [[C_4:%.*]] = icmp ule i32 [[X]], [[Z]]
92 ; CHECK-NEXT: call void @use(i1 [[C_4]])
93 ; CHECK-NEXT: [[C_5:%.*]] = icmp ule i32 [[X]], [[A]]
94 ; CHECK-NEXT: call void @use(i1 [[C_5]])
95 ; CHECK-NEXT: [[C_6:%.*]] = icmp ule i32 [[X]], [[Y]]
96 ; CHECK-NEXT: call void @use(i1 [[C_6]])
97 ; CHECK-NEXT: [[C_7:%.*]] = icmp ule i32 [[Y]], [[Z]]
98 ; CHECK-NEXT: call void @use(i1 [[C_7]])
99 ; CHECK-NEXT: ret i32 20
102 %c.1 = icmp ule i32 %x, %y
103 %c.2 = icmp ule i32 %y, %z
104 %and = select i1 %c.1, i1 %c.2, i1 false
105 br i1 %and, label %bb1, label %exit
108 %t.1 = icmp ule i32 %x, %z
109 call void @use(i1 %t.1)
111 %t.2 = icmp ule i32 %x, %y
112 call void @use(i1 %t.2)
114 %t.3 = icmp ule i32 %y, %z
115 call void @use(i1 %t.3)
118 %c.3 = icmp ule i32 %x, %a
119 call void @use(i1 %c.3)
124 %c.4 = icmp ule i32 %x, %z
125 call void @use(i1 %c.4)
127 %c.5 = icmp ule i32 %x, %a
128 call void @use(i1 %c.5)
130 %c.6 = icmp ule i32 %x, %y
131 call void @use(i1 %c.6)
133 %c.7 = icmp ule i32 %y, %z
134 call void @use(i1 %c.7)
139 define i4 @and_compare_undef(i16 %N, i16 %step) {
140 ; CHECK-LABEL: @and_compare_undef(
141 ; CHECK-NEXT: step.check:
142 ; CHECK-NEXT: [[STEP_POS:%.*]] = icmp uge i16 [[STEP:%.*]], 0
143 ; CHECK-NEXT: [[B1:%.*]] = add i16 undef, -1
144 ; CHECK-NEXT: [[STEP_ULT_N:%.*]] = icmp ult i16 [[B1]], [[N:%.*]]
145 ; CHECK-NEXT: [[AND_STEP:%.*]] = and i1 [[STEP_POS]], [[STEP_ULT_N]]
146 ; CHECK-NEXT: br i1 [[AND_STEP]], label [[PTR_CHECK:%.*]], label [[EXIT:%.*]]
148 ; CHECK-NEXT: br label [[EXIT]]
150 ; CHECK-NEXT: ret i4 3
153 %step.pos = icmp uge i16 %step, 0
154 %B1 = add i16 undef, -1
155 %step.ult.N = icmp ult i16 %B1, %N
156 %and.step = and i1 %step.pos, %step.ult.N
157 br i1 %and.step, label %ptr.check, label %exit