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_eq_1(i8 %a, i8 %b) {
5 ; CHECK-LABEL: @test_eq_1(
7 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[A:%.*]], [[B:%.*]]
8 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
10 ; CHECK-NEXT: [[T_1:%.*]] = icmp uge i8 [[A]], [[B]]
11 ; CHECK-NEXT: [[T_2:%.*]] = icmp ule i8 [[A]], [[B]]
12 ; CHECK-NEXT: [[RES_1:%.*]] = xor i1 true, true
13 ; CHECK-NEXT: [[T_3:%.*]] = icmp eq i8 [[A]], [[B]]
14 ; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], [[T_3]]
15 ; CHECK-NEXT: [[T_4:%.*]] = icmp eq i8 [[B]], [[A]]
16 ; CHECK-NEXT: [[RES_3:%.*]] = xor i1 [[RES_2]], [[T_4]]
17 ; CHECK-NEXT: [[F_1:%.*]] = icmp ugt i8 [[B]], [[A]]
18 ; CHECK-NEXT: [[RES_4:%.*]] = xor i1 [[RES_3]], false
19 ; CHECK-NEXT: [[F_2:%.*]] = icmp ult i8 [[B]], [[A]]
20 ; CHECK-NEXT: [[RES_5:%.*]] = xor i1 [[RES_4]], false
21 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[B]], 99
22 ; CHECK-NEXT: [[RES_6:%.*]] = xor i1 [[RES_5]], [[C_1]]
23 ; CHECK-NEXT: ret i1 [[RES_6]]
25 ; CHECK-NEXT: [[F_3:%.*]] = icmp eq i8 [[A]], [[B]]
26 ; CHECK-NEXT: [[F_4:%.*]] = icmp eq i8 [[B]], [[A]]
27 ; CHECK-NEXT: [[RES_7:%.*]] = xor i1 [[F_3]], [[F_4]]
28 ; CHECK-NEXT: [[C_2:%.*]] = icmp ult i8 [[B]], 99
29 ; CHECK-NEXT: [[RES_8:%.*]] = xor i1 [[RES_7]], [[C_2]]
30 ; CHECK-NEXT: [[C_3:%.*]] = icmp uge i8 [[A]], [[B]]
31 ; CHECK-NEXT: [[RES_9:%.*]] = xor i1 [[RES_8]], [[C_3]]
32 ; CHECK-NEXT: [[C_4:%.*]] = icmp ule i8 [[A]], [[B]]
33 ; CHECK-NEXT: [[RES_10:%.*]] = xor i1 [[RES_9]], [[C_4]]
34 ; CHECK-NEXT: [[C_5:%.*]] = icmp ugt i8 [[B]], [[A]]
35 ; CHECK-NEXT: [[RES_11:%.*]] = xor i1 [[RES_10]], [[C_5]]
36 ; CHECK-NEXT: [[C_6:%.*]] = icmp ult i8 [[B]], [[A]]
37 ; CHECK-NEXT: [[RES_12:%.*]] = xor i1 [[RES_11]], [[C_6]]
38 ; CHECK-NEXT: ret i1 [[RES_12]]
41 %cmp = icmp eq i8 %a, %b
42 br i1 %cmp, label %then, label %else
45 %t.1 = icmp uge i8 %a, %b
46 %t.2 = icmp ule i8 %a, %b
47 %res.1 = xor i1 %t.1, %t.2
49 %t.3 = icmp eq i8 %a, %b
50 %res.2 = xor i1 %res.1, %t.3
52 %t.4 = icmp eq i8 %b, %a
53 %res.3 = xor i1 %res.2, %t.4
55 %f.1 = icmp ugt i8 %b, %a
56 %res.4 = xor i1 %res.3, %f.1
58 %f.2 = icmp ult i8 %b, %a
59 %res.5 = xor i1 %res.4, %f.2
61 %c.1 = icmp ult i8 %b, 99
62 %res.6 = xor i1 %res.5, %c.1
66 %f.3 = icmp eq i8 %a, %b
67 %f.4 = icmp eq i8 %b, %a
68 %res.7 = xor i1 %f.3, %f.4
70 %c.2 = icmp ult i8 %b, 99
71 %res.8 = xor i1 %res.7, %c.2
73 %c.3 = icmp uge i8 %a, %b
74 %res.9 = xor i1 %res.8, %c.3
76 %c.4 = icmp ule i8 %a, %b
77 %res.10 = xor i1 %res.9, %c.4
79 %c.5 = icmp ugt i8 %b, %a
80 %res.11 = xor i1 %res.10, %c.5
82 %c.6 = icmp ult i8 %b, %a
83 %res.12 = xor i1 %res.11, %c.6
87 define i1 @test_eq_2(i8 %a, i8 %b) {
88 ; CHECK-LABEL: @test_eq_2(
90 ; CHECK-NEXT: [[PRE_1:%.*]] = icmp eq i8 [[A:%.*]], [[B:%.*]]
91 ; CHECK-NEXT: br i1 [[PRE_1]], label [[THEN:%.*]], label [[ELSE:%.*]]
93 ; CHECK-NEXT: [[PRE_3:%.*]] = icmp ult i8 [[B]], 100
94 ; CHECK-NEXT: br i1 [[PRE_3]], label [[THEN_THEN:%.*]], label [[THEN_ELSE:%.*]]
96 ; CHECK-NEXT: [[T_1:%.*]] = icmp ult i8 [[A]], 100
97 ; CHECK-NEXT: [[T_2:%.*]] = icmp ult i8 [[B]], 100
98 ; CHECK-NEXT: [[XOR_1:%.*]] = xor i1 true, true
99 ; CHECK-NEXT: [[F_1:%.*]] = icmp uge i8 [[A]], 100
100 ; CHECK-NEXT: [[XOR_2:%.*]] = xor i1 [[XOR_1]], false
101 ; CHECK-NEXT: [[F_2:%.*]] = icmp uge i8 [[B]], 100
102 ; CHECK-NEXT: [[XOR_3:%.*]] = xor i1 [[XOR_2]], false
103 ; CHECK-NEXT: [[F_3_1:%.*]] = icmp ugt i8 [[A]], 99
104 ; CHECK-NEXT: [[XOR_4:%.*]] = xor i1 [[XOR_3]], false
105 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[A]], 99
106 ; CHECK-NEXT: [[XOR_5:%.*]] = xor i1 [[XOR_4]], [[C_1]]
107 ; CHECK-NEXT: [[C_2:%.*]] = icmp ugt i8 [[A]], 98
108 ; CHECK-NEXT: [[XOR_6:%.*]] = xor i1 [[XOR_5]], [[C_1]]
109 ; CHECK-NEXT: ret i1 [[XOR_6]]
111 ; CHECK-NEXT: [[F_4:%.*]] = icmp ult i8 [[A]], 100
112 ; CHECK-NEXT: [[F_5:%.*]] = icmp ult i8 [[B]], 100
113 ; CHECK-NEXT: [[XOR_7:%.*]] = xor i1 false, false
114 ; CHECK-NEXT: [[T_3:%.*]] = icmp uge i8 [[A]], 100
115 ; CHECK-NEXT: [[XOR_8:%.*]] = xor i1 [[XOR_7]], true
116 ; CHECK-NEXT: [[T_4:%.*]] = icmp uge i8 [[B]], 100
117 ; CHECK-NEXT: [[XOR_9:%.*]] = xor i1 [[XOR_8]], true
118 ; CHECK-NEXT: [[T_5:%.*]] = icmp ugt i8 [[A]], 99
119 ; CHECK-NEXT: [[XOR_10:%.*]] = xor i1 [[XOR_9]], true
120 ; CHECK-NEXT: [[C_3:%.*]] = icmp ult i8 [[A]], 99
121 ; CHECK-NEXT: [[XOR_11:%.*]] = xor i1 [[XOR_10]], false
122 ; CHECK-NEXT: [[C_4:%.*]] = icmp ugt i8 [[A]], 98
123 ; CHECK-NEXT: [[XOR_12:%.*]] = xor i1 [[XOR_11]], true
124 ; CHECK-NEXT: ret i1 [[XOR_12]]
126 ; CHECK-NEXT: [[CMP_2:%.*]] = icmp ult i8 [[A]], 100
127 ; CHECK-NEXT: ret i1 [[CMP_2]]
130 %pre.1 = icmp eq i8 %a, %b
131 br i1 %pre.1, label %then, label %else
134 %pre.3 = icmp ult i8 %b, 100
135 br i1 %pre.3, label %then.then, label %then.else
138 %t.1 = icmp ult i8 %a, 100
139 %t.2 = icmp ult i8 %b, 100
140 %xor.1 = xor i1 %t.1, %t.2
142 %f.1 = icmp uge i8 %a, 100
143 %xor.2 = xor i1 %xor.1, %f.1
145 %f.2 = icmp uge i8 %b, 100
146 %xor.3 = xor i1 %xor.2, %f.2
148 %f.3.1 = icmp ugt i8 %a, 99
149 %xor.4 = xor i1 %xor.3, %f.3.1
151 %c.1 = icmp ult i8 %a, 99
152 %xor.5 = xor i1 %xor.4, %c.1
154 %c.2 = icmp ugt i8 %a, 98
155 %xor.6 = xor i1 %xor.5, %c.1
160 %f.4 = icmp ult i8 %a, 100
161 %f.5 = icmp ult i8 %b, 100
162 %xor.7 = xor i1 %f.4, %f.5
164 %t.3 = icmp uge i8 %a, 100
165 %xor.8 = xor i1 %xor.7, %t.3
167 %t.4 = icmp uge i8 %b, 100
168 %xor.9 = xor i1 %xor.8, %t.4
170 %t.5 = icmp ugt i8 %a, 99
171 %xor.10 = xor i1 %xor.9, %t.5
173 %c.3 = icmp ult i8 %a, 99
174 %xor.11 = xor i1 %xor.10, %c.3
176 %c.4 = icmp ugt i8 %a, 98
177 %xor.12 = xor i1 %xor.11, %c.4
182 %cmp.2 = icmp ult i8 %a, 100
186 ; Test of explicitly using uge & ule instead of eq.
187 define i1 @test_eq_as_uge_ule_(i8 %a, i8 %b) {
188 ; CHECK-LABEL: @test_eq_as_uge_ule_(
190 ; CHECK-NEXT: [[PRE_1:%.*]] = icmp uge i8 [[A:%.*]], [[B:%.*]]
191 ; CHECK-NEXT: [[PRE_2:%.*]] = icmp ule i8 [[A]], [[B]]
192 ; CHECK-NEXT: [[PRE_AND:%.*]] = and i1 [[PRE_1]], [[PRE_2]]
193 ; CHECK-NEXT: br i1 [[PRE_AND]], label [[THEN:%.*]], label [[ELSE:%.*]]
195 ; CHECK-NEXT: [[PRE_3:%.*]] = icmp ult i8 [[B]], 100
196 ; CHECK-NEXT: br i1 [[PRE_3]], label [[THEN_THEN:%.*]], label [[THEN_ELSE:%.*]]
198 ; CHECK-NEXT: [[T_1:%.*]] = icmp ult i8 [[A]], 100
199 ; CHECK-NEXT: [[T_2:%.*]] = icmp ult i8 [[B]], 100
200 ; CHECK-NEXT: [[XOR_1:%.*]] = xor i1 true, true
201 ; CHECK-NEXT: [[F_1:%.*]] = icmp uge i8 [[A]], 100
202 ; CHECK-NEXT: [[XOR_2:%.*]] = xor i1 [[XOR_1]], false
203 ; CHECK-NEXT: [[F_2:%.*]] = icmp uge i8 [[B]], 100
204 ; CHECK-NEXT: [[XOR_3:%.*]] = xor i1 [[XOR_2]], false
205 ; CHECK-NEXT: [[F_3_1:%.*]] = icmp ugt i8 [[A]], 99
206 ; CHECK-NEXT: [[XOR_4:%.*]] = xor i1 [[XOR_3]], false
207 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[A]], 99
208 ; CHECK-NEXT: [[XOR_5:%.*]] = xor i1 [[XOR_4]], [[C_1]]
209 ; CHECK-NEXT: [[C_2:%.*]] = icmp ugt i8 [[A]], 98
210 ; CHECK-NEXT: [[XOR_6:%.*]] = xor i1 [[XOR_5]], [[C_1]]
211 ; CHECK-NEXT: ret i1 [[XOR_6]]
213 ; CHECK-NEXT: [[F_4:%.*]] = icmp ult i8 [[A]], 100
214 ; CHECK-NEXT: [[F_5:%.*]] = icmp ult i8 [[B]], 100
215 ; CHECK-NEXT: [[XOR_7:%.*]] = xor i1 false, false
216 ; CHECK-NEXT: [[T_3:%.*]] = icmp uge i8 [[A]], 100
217 ; CHECK-NEXT: [[XOR_8:%.*]] = xor i1 [[XOR_7]], true
218 ; CHECK-NEXT: [[T_4:%.*]] = icmp uge i8 [[B]], 100
219 ; CHECK-NEXT: [[XOR_9:%.*]] = xor i1 [[XOR_8]], true
220 ; CHECK-NEXT: [[T_5:%.*]] = icmp ugt i8 [[A]], 99
221 ; CHECK-NEXT: [[XOR_10:%.*]] = xor i1 [[XOR_9]], true
222 ; CHECK-NEXT: [[C_3:%.*]] = icmp ult i8 [[A]], 99
223 ; CHECK-NEXT: [[XOR_11:%.*]] = xor i1 [[XOR_10]], false
224 ; CHECK-NEXT: [[C_4:%.*]] = icmp ugt i8 [[A]], 98
225 ; CHECK-NEXT: [[XOR_12:%.*]] = xor i1 [[XOR_11]], true
226 ; CHECK-NEXT: ret i1 [[XOR_12]]
228 ; CHECK-NEXT: [[CMP_2:%.*]] = icmp ult i8 [[A]], 100
229 ; CHECK-NEXT: ret i1 [[CMP_2]]
232 %pre.1 = icmp uge i8 %a, %b
233 %pre.2 = icmp ule i8 %a, %b
234 %pre.and = and i1 %pre.1, %pre.2
235 br i1 %pre.and, label %then, label %else
238 %pre.3 = icmp ult i8 %b, 100
239 br i1 %pre.3, label %then.then, label %then.else
242 %t.1 = icmp ult i8 %a, 100
243 %t.2 = icmp ult i8 %b, 100
244 %xor.1 = xor i1 %t.1, %t.2
246 %f.1 = icmp uge i8 %a, 100
247 %xor.2 = xor i1 %xor.1, %f.1
249 %f.2 = icmp uge i8 %b, 100
250 %xor.3 = xor i1 %xor.2, %f.2
252 %f.3.1 = icmp ugt i8 %a, 99
253 %xor.4 = xor i1 %xor.3, %f.3.1
255 %c.1 = icmp ult i8 %a, 99
256 %xor.5 = xor i1 %xor.4, %c.1
258 %c.2 = icmp ugt i8 %a, 98
259 %xor.6 = xor i1 %xor.5, %c.1
264 %f.4 = icmp ult i8 %a, 100
265 %f.5 = icmp ult i8 %b, 100
266 %xor.7 = xor i1 %f.4, %f.5
268 %t.3 = icmp uge i8 %a, 100
269 %xor.8 = xor i1 %xor.7, %t.3
271 %t.4 = icmp uge i8 %b, 100
272 %xor.9 = xor i1 %xor.8, %t.4
274 %t.5 = icmp ugt i8 %a, 99
275 %xor.10 = xor i1 %xor.9, %t.5
277 %c.3 = icmp ult i8 %a, 99
278 %xor.11 = xor i1 %xor.10, %c.3
280 %c.4 = icmp ugt i8 %a, 98
281 %xor.12 = xor i1 %xor.11, %c.4
286 %cmp.2 = icmp ult i8 %a, 100
291 define i1 @test_eq_ult_and(i8 %a, i8 %b) {
292 ; CHECK-LABEL: @test_eq_ult_and(
294 ; CHECK-NEXT: [[PRE_1:%.*]] = icmp eq i8 [[A:%.*]], [[B:%.*]]
295 ; CHECK-NEXT: [[PRE_2:%.*]] = icmp ult i8 [[B]], 100
296 ; CHECK-NEXT: [[PRE_AND:%.*]] = and i1 [[PRE_1]], [[PRE_2]]
297 ; CHECK-NEXT: br i1 [[PRE_AND]], label [[THEN:%.*]], label [[ELSE:%.*]]
299 ; CHECK-NEXT: [[T_1:%.*]] = icmp ult i8 [[A]], 100
300 ; CHECK-NEXT: [[T_2:%.*]] = icmp ult i8 [[B]], 100
301 ; CHECK-NEXT: [[XOR_1:%.*]] = xor i1 true, true
302 ; CHECK-NEXT: [[F_1:%.*]] = icmp uge i8 [[A]], 100
303 ; CHECK-NEXT: [[XOR_2:%.*]] = xor i1 [[XOR_1]], false
304 ; CHECK-NEXT: [[F_2:%.*]] = icmp uge i8 [[B]], 100
305 ; CHECK-NEXT: [[XOR_3:%.*]] = xor i1 [[XOR_2]], false
306 ; CHECK-NEXT: [[F_3_1:%.*]] = icmp ugt i8 [[A]], 99
307 ; CHECK-NEXT: [[XOR_4:%.*]] = xor i1 [[XOR_3]], false
308 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[A]], 99
309 ; CHECK-NEXT: [[XOR_5:%.*]] = xor i1 [[XOR_4]], [[C_1]]
310 ; CHECK-NEXT: [[C_2:%.*]] = icmp ugt i8 [[A]], 98
311 ; CHECK-NEXT: [[XOR_6:%.*]] = xor i1 [[XOR_5]], [[C_1]]
312 ; CHECK-NEXT: ret i1 [[XOR_6]]
314 ; CHECK-NEXT: [[F_4:%.*]] = icmp ult i8 [[A]], 100
315 ; CHECK-NEXT: [[F_5:%.*]] = icmp ult i8 [[B]], 100
316 ; CHECK-NEXT: [[XOR_7:%.*]] = xor i1 [[F_4]], [[F_5]]
317 ; CHECK-NEXT: [[T_3:%.*]] = icmp uge i8 [[A]], 100
318 ; CHECK-NEXT: [[XOR_8:%.*]] = xor i1 [[XOR_7]], [[T_3]]
319 ; CHECK-NEXT: [[T_4:%.*]] = icmp uge i8 [[B]], 100
320 ; CHECK-NEXT: [[XOR_9:%.*]] = xor i1 [[XOR_8]], [[T_4]]
321 ; CHECK-NEXT: [[T_5:%.*]] = icmp ugt i8 [[A]], 99
322 ; CHECK-NEXT: [[XOR_10:%.*]] = xor i1 [[XOR_9]], [[T_5]]
323 ; CHECK-NEXT: [[C_3:%.*]] = icmp ult i8 [[A]], 99
324 ; CHECK-NEXT: [[XOR_11:%.*]] = xor i1 [[XOR_10]], [[C_3]]
325 ; CHECK-NEXT: [[C_4:%.*]] = icmp ugt i8 [[A]], 98
326 ; CHECK-NEXT: [[XOR_12:%.*]] = xor i1 [[XOR_11]], [[C_4]]
327 ; CHECK-NEXT: ret i1 [[XOR_12]]
330 %pre.1 = icmp eq i8 %a, %b
331 %pre.2 = icmp ult i8 %b, 100
332 %pre.and = and i1 %pre.1, %pre.2
333 br i1 %pre.and, label %then, label %else
336 %t.1 = icmp ult i8 %a, 100
337 %t.2 = icmp ult i8 %b, 100
338 %xor.1 = xor i1 %t.1, %t.2
340 %f.1 = icmp uge i8 %a, 100
341 %xor.2 = xor i1 %xor.1, %f.1
343 %f.2 = icmp uge i8 %b, 100
344 %xor.3 = xor i1 %xor.2, %f.2
346 %f.3.1 = icmp ugt i8 %a, 99
347 %xor.4 = xor i1 %xor.3, %f.3.1
349 %c.1 = icmp ult i8 %a, 99
350 %xor.5 = xor i1 %xor.4, %c.1
352 %c.2 = icmp ugt i8 %a, 98
353 %xor.6 = xor i1 %xor.5, %c.1
358 %f.4 = icmp ult i8 %a, 100
359 %f.5 = icmp ult i8 %b, 100
360 %xor.7 = xor i1 %f.4, %f.5
362 %t.3 = icmp uge i8 %a, 100
363 %xor.8 = xor i1 %xor.7, %t.3
365 %t.4 = icmp uge i8 %b, 100
366 %xor.9 = xor i1 %xor.8, %t.4
368 %t.5 = icmp ugt i8 %a, 99
369 %xor.10 = xor i1 %xor.9, %t.5
371 %c.3 = icmp ult i8 %a, 99
372 %xor.11 = xor i1 %xor.10, %c.3
374 %c.4 = icmp ugt i8 %a, 98
375 %xor.12 = xor i1 %xor.11, %c.4