1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
6 define i1 @set_low_bit_mask_eq(i8 %x) {
7 ; CHECK-LABEL: @set_low_bit_mask_eq(
8 ; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[X:%.*]], -2
9 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[TMP1]], 18
10 ; CHECK-NEXT: ret i1 [[CMP]]
13 %cmp = icmp eq i8 %sub, 19
17 define <2 x i1> @set_low_bit_mask_ne(<2 x i8> %x) {
18 ; CHECK-LABEL: @set_low_bit_mask_ne(
19 ; CHECK-NEXT: [[TMP1:%.*]] = and <2 x i8> [[X:%.*]], splat (i8 -4)
20 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i8> [[TMP1]], splat (i8 16)
21 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
23 %sub = or <2 x i8> %x, <i8 3, i8 3>
24 %cmp = icmp ne <2 x i8> %sub, <i8 19, i8 19>
28 define i1 @set_low_bit_mask_ugt(i8 %x) {
29 ; CHECK-LABEL: @set_low_bit_mask_ugt(
30 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], 19
31 ; CHECK-NEXT: ret i1 [[CMP]]
34 %cmp = icmp ugt i8 %sub, 19
38 define i1 @set_low_bit_mask_ult(i8 %x) {
39 ; CHECK-LABEL: @set_low_bit_mask_ult(
40 ; CHECK-NEXT: [[SUB:%.*]] = or i8 [[X:%.*]], 3
41 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[SUB]], 19
42 ; CHECK-NEXT: ret i1 [[CMP]]
45 %cmp = icmp ult i8 %sub, 19
49 define i1 @set_low_bit_mask_uge(i8 %x) {
50 ; CHECK-LABEL: @set_low_bit_mask_uge(
51 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], 19
52 ; CHECK-NEXT: ret i1 [[CMP]]
55 %cmp = icmp uge i8 %sub, 20
59 define i1 @set_low_bit_mask_ule(i8 %x) {
60 ; CHECK-LABEL: @set_low_bit_mask_ule(
61 ; CHECK-NEXT: [[SUB:%.*]] = or i8 [[X:%.*]], 3
62 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[SUB]], 19
63 ; CHECK-NEXT: ret i1 [[CMP]]
66 %cmp = icmp ule i8 %sub, 18
70 define i1 @set_low_bit_mask_sgt(i8 %x) {
71 ; CHECK-LABEL: @set_low_bit_mask_sgt(
72 ; CHECK-NEXT: [[SUB:%.*]] = or i8 [[X:%.*]], 3
73 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[SUB]], 20
74 ; CHECK-NEXT: ret i1 [[CMP]]
77 %cmp = icmp sgt i8 %sub, 20
81 define i1 @set_low_bit_mask_slt(i8 %x) {
82 ; CHECK-LABEL: @set_low_bit_mask_slt(
83 ; CHECK-NEXT: [[SUB:%.*]] = or i8 [[X:%.*]], 15
84 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[SUB]], 19
85 ; CHECK-NEXT: ret i1 [[CMP]]
88 %cmp = icmp slt i8 %sub, 19
92 define i1 @set_low_bit_mask_sge(i8 %x) {
93 ; CHECK-LABEL: @set_low_bit_mask_sge(
94 ; CHECK-NEXT: [[SUB:%.*]] = or i8 [[X:%.*]], 31
95 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[SUB]], 50
96 ; CHECK-NEXT: ret i1 [[CMP]]
99 %cmp = icmp sge i8 %sub, 51
103 define i1 @set_low_bit_mask_sle(i8 %x) {
104 ; CHECK-LABEL: @set_low_bit_mask_sle(
105 ; CHECK-NEXT: [[SUB:%.*]] = or i8 [[X:%.*]], 63
106 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[SUB]], 69
107 ; CHECK-NEXT: ret i1 [[CMP]]
110 %cmp = icmp sle i8 %sub, 68
114 define i1 @eq_const_mask(i8 %x, i8 %y) {
115 ; CHECK-LABEL: @eq_const_mask(
116 ; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[X:%.*]], [[Y:%.*]]
117 ; CHECK-NEXT: [[TMP2:%.*]] = and i8 [[TMP1]], -43
118 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[TMP2]], 0
119 ; CHECK-NEXT: ret i1 [[CMP]]
123 %cmp = icmp eq i8 %b0, %b1
127 define <2 x i1> @ne_const_mask(<2 x i8> %x, <2 x i8> %y) {
128 ; CHECK-LABEL: @ne_const_mask(
129 ; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i8> [[X:%.*]], [[Y:%.*]]
130 ; CHECK-NEXT: [[TMP2:%.*]] = and <2 x i8> [[TMP1]], <i8 105, i8 -6>
131 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i8> [[TMP2]], zeroinitializer
132 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
134 %b0 = or <2 x i8> %x, <i8 150, i8 5>
135 %b1 = or <2 x i8> %y, <i8 150, i8 5>
136 %cmp = icmp ne <2 x i8> %b0, %b1
140 ; negative test - predicate
142 define i1 @eq_const_mask_not_equality(i8 %x, i8 %y) {
143 ; CHECK-LABEL: @eq_const_mask_not_equality(
144 ; CHECK-NEXT: [[B0:%.*]] = or i8 [[X:%.*]], 5
145 ; CHECK-NEXT: [[B1:%.*]] = or i8 [[Y:%.*]], 5
146 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[B0]], [[B1]]
147 ; CHECK-NEXT: ret i1 [[CMP]]
151 %cmp = icmp sgt i8 %b0, %b1
155 ; negative test - mismatched constants
157 define i1 @eq_const_mask_not_same(i8 %x, i8 %y) {
158 ; CHECK-LABEL: @eq_const_mask_not_same(
159 ; CHECK-NEXT: [[B0:%.*]] = or i8 [[X:%.*]], 5
160 ; CHECK-NEXT: [[B1:%.*]] = or i8 [[Y:%.*]], 6
161 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[B0]], [[B1]]
162 ; CHECK-NEXT: ret i1 [[CMP]]
166 %cmp = icmp eq i8 %b0, %b1
170 ; negative test - mismatched logic
172 define i1 @eq_const_mask_wrong_opcode(i8 %x, i8 %y) {
173 ; CHECK-LABEL: @eq_const_mask_wrong_opcode(
174 ; CHECK-NEXT: [[B0:%.*]] = or i8 [[X:%.*]], 5
175 ; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[Y:%.*]], [[B0]]
176 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[TMP1]], 5
177 ; CHECK-NEXT: ret i1 [[CMP]]
181 %cmp = icmp eq i8 %b0, %b1
185 ; negative test - no extra uses
187 define i1 @eq_const_mask_use1(i8 %x, i8 %y) {
188 ; CHECK-LABEL: @eq_const_mask_use1(
189 ; CHECK-NEXT: [[B0:%.*]] = or i8 [[X:%.*]], 5
190 ; CHECK-NEXT: call void @use(i8 [[B0]])
191 ; CHECK-NEXT: [[B1:%.*]] = or i8 [[Y:%.*]], 5
192 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[B0]], [[B1]]
193 ; CHECK-NEXT: ret i1 [[CMP]]
196 call void @use(i8 %b0)
198 %cmp = icmp eq i8 %b0, %b1
202 ; negative test - no extra uses
204 define i1 @eq_const_mask_use2(i8 %x, i8 %y) {
205 ; CHECK-LABEL: @eq_const_mask_use2(
206 ; CHECK-NEXT: [[B0:%.*]] = or i8 [[X:%.*]], 5
207 ; CHECK-NEXT: [[B1:%.*]] = or i8 [[Y:%.*]], 5
208 ; CHECK-NEXT: call void @use(i8 [[B1]])
209 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[B0]], [[B1]]
210 ; CHECK-NEXT: ret i1 [[CMP]]
214 call void @use(i8 %b1)
215 %cmp = icmp eq i8 %b0, %b1
221 define <2 x i1> @decrement_slt_0(<2 x i8> %x) {
222 ; CHECK-LABEL: @decrement_slt_0(
223 ; CHECK-NEXT: [[R:%.*]] = icmp slt <2 x i8> [[X:%.*]], splat (i8 1)
224 ; CHECK-NEXT: ret <2 x i1> [[R]]
226 %dec = add <2 x i8> %x, <i8 -1, i8 -1>
227 %or = or <2 x i8> %dec, %x
228 %r = icmp slt <2 x i8> %or, zeroinitializer
232 define i1 @decrement_slt_0_commute_use1(i8 %px) {
233 ; CHECK-LABEL: @decrement_slt_0_commute_use1(
234 ; CHECK-NEXT: [[X:%.*]] = mul i8 [[PX:%.*]], 42
235 ; CHECK-NEXT: [[DEC:%.*]] = add i8 [[X]], -1
236 ; CHECK-NEXT: call void @use(i8 [[DEC]])
237 ; CHECK-NEXT: [[R:%.*]] = icmp slt i8 [[X]], 1
238 ; CHECK-NEXT: ret i1 [[R]]
240 %x = mul i8 %px, 42 ; thwart complexity-based canonicalization
242 call void @use(i8 %dec)
244 %r = icmp slt i8 %or, 0
248 define i1 @decrement_slt_0_use2(i8 %x) {
249 ; CHECK-LABEL: @decrement_slt_0_use2(
250 ; CHECK-NEXT: [[DEC:%.*]] = add i8 [[X:%.*]], -1
251 ; CHECK-NEXT: [[OR:%.*]] = or i8 [[DEC]], [[X]]
252 ; CHECK-NEXT: call void @use(i8 [[OR]])
253 ; CHECK-NEXT: [[R:%.*]] = icmp slt i8 [[X]], 1
254 ; CHECK-NEXT: ret i1 [[R]]
258 call void @use(i8 %or)
259 %r = icmp slt i8 %or, 0
263 ; negative test - wrong cmp constant
265 define i1 @decrement_slt_n1(i8 %x) {
266 ; CHECK-LABEL: @decrement_slt_n1(
267 ; CHECK-NEXT: [[DEC:%.*]] = add i8 [[X:%.*]], -1
268 ; CHECK-NEXT: [[OR:%.*]] = or i8 [[DEC]], [[X]]
269 ; CHECK-NEXT: [[R:%.*]] = icmp slt i8 [[OR]], -1
270 ; CHECK-NEXT: ret i1 [[R]]
274 %r = icmp slt i8 %or, -1
278 ; negative test - wrong add constant
280 define i1 @not_decrement_slt_0(i8 %x) {
281 ; CHECK-LABEL: @not_decrement_slt_0(
282 ; CHECK-NEXT: [[DEC:%.*]] = add i8 [[X:%.*]], -2
283 ; CHECK-NEXT: [[OR:%.*]] = or i8 [[DEC]], [[X]]
284 ; CHECK-NEXT: [[R:%.*]] = icmp slt i8 [[OR]], 0
285 ; CHECK-NEXT: ret i1 [[R]]
289 %r = icmp slt i8 %or, 0
293 ; (x | (x - 1)) s> -1
295 define <2 x i1> @decrement_sgt_n1(<2 x i8> %x) {
296 ; CHECK-LABEL: @decrement_sgt_n1(
297 ; CHECK-NEXT: [[R:%.*]] = icmp sgt <2 x i8> [[X:%.*]], zeroinitializer
298 ; CHECK-NEXT: ret <2 x i1> [[R]]
300 %dec = add <2 x i8> %x, <i8 -1, i8 -1>
301 %or = or <2 x i8> %dec, %x
302 %r = icmp sgt <2 x i8> %or, <i8 -1, i8 -1>
306 define i1 @decrement_sgt_n1_commute_use1(i8 %px) {
307 ; CHECK-LABEL: @decrement_sgt_n1_commute_use1(
308 ; CHECK-NEXT: [[X:%.*]] = mul i8 [[PX:%.*]], 42
309 ; CHECK-NEXT: [[DEC:%.*]] = add i8 [[X]], -1
310 ; CHECK-NEXT: call void @use(i8 [[DEC]])
311 ; CHECK-NEXT: [[R:%.*]] = icmp sgt i8 [[X]], 0
312 ; CHECK-NEXT: ret i1 [[R]]
314 %x = mul i8 %px, 42 ; thwart complexity-based canonicalization
316 call void @use(i8 %dec)
318 %r = icmp sgt i8 %or, -1
322 define i1 @decrement_sgt_n1_use2(i8 %x) {
323 ; CHECK-LABEL: @decrement_sgt_n1_use2(
324 ; CHECK-NEXT: [[DEC:%.*]] = add i8 [[X:%.*]], -1
325 ; CHECK-NEXT: [[OR:%.*]] = or i8 [[DEC]], [[X]]
326 ; CHECK-NEXT: call void @use(i8 [[OR]])
327 ; CHECK-NEXT: [[R:%.*]] = icmp sgt i8 [[X]], 0
328 ; CHECK-NEXT: ret i1 [[R]]
332 call void @use(i8 %or)
333 %r = icmp sgt i8 %or, -1
337 ; negative test - wrong cmp constant
339 define i1 @decrement_sgt_0(i8 %x) {
340 ; CHECK-LABEL: @decrement_sgt_0(
341 ; CHECK-NEXT: [[DEC:%.*]] = add i8 [[X:%.*]], -1
342 ; CHECK-NEXT: [[OR:%.*]] = or i8 [[DEC]], [[X]]
343 ; CHECK-NEXT: [[R:%.*]] = icmp sgt i8 [[OR]], 0
344 ; CHECK-NEXT: ret i1 [[R]]
348 %r = icmp sgt i8 %or, 0
352 ; negative test - wrong add constant
354 define i1 @not_decrement_sgt_n1(i8 %x) {
355 ; CHECK-LABEL: @not_decrement_sgt_n1(
356 ; CHECK-NEXT: [[DEC:%.*]] = add i8 [[X:%.*]], -2
357 ; CHECK-NEXT: [[OR:%.*]] = or i8 [[DEC]], [[X]]
358 ; CHECK-NEXT: [[R:%.*]] = icmp sgt i8 [[OR]], -1
359 ; CHECK-NEXT: ret i1 [[R]]
363 %r = icmp sgt i8 %or, -1
367 define i1 @icmp_or_xor_2_eq(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
368 ; CHECK-LABEL: @icmp_or_xor_2_eq(
369 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[X1:%.*]], [[Y1:%.*]]
370 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[X2:%.*]], [[Y2:%.*]]
371 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP1]], [[TMP2]]
372 ; CHECK-NEXT: ret i1 [[CMP]]
374 %xor = xor i64 %x1, %y1
375 %xor1 = xor i64 %x2, %y2
376 %or = or i64 %xor, %xor1
377 %cmp = icmp eq i64 %or, 0
381 define i1 @icmp_or_xor_2_ne(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
382 ; CHECK-LABEL: @icmp_or_xor_2_ne(
383 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i64 [[X1:%.*]], [[Y1:%.*]]
384 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i64 [[X2:%.*]], [[Y2:%.*]]
385 ; CHECK-NEXT: [[CMP:%.*]] = or i1 [[TMP1]], [[TMP2]]
386 ; CHECK-NEXT: ret i1 [[CMP]]
388 %xor = xor i64 %x1, %y1
389 %xor1 = xor i64 %x2, %y2
390 %or = or i64 %xor, %xor1
391 %cmp = icmp ne i64 %or, 0
395 ; negative test - wrong cmp constant
397 define i1 @icmp_or_xor_2_eq_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
398 ; CHECK-LABEL: @icmp_or_xor_2_eq_fail(
399 ; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
400 ; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
401 ; CHECK-NEXT: [[OR:%.*]] = or i64 [[XOR]], [[XOR1]]
402 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR]], 1
403 ; CHECK-NEXT: ret i1 [[CMP]]
405 %xor = xor i64 %x1, %y1
406 %xor1 = xor i64 %x2, %y2
407 %or = or i64 %xor, %xor1
408 %cmp = icmp eq i64 %or, 1
412 ; negative test - wrong cmp constant
414 define i1 @icmp_or_xor_2_ne_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
415 ; CHECK-LABEL: @icmp_or_xor_2_ne_fail(
416 ; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
417 ; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
418 ; CHECK-NEXT: [[OR:%.*]] = or i64 [[XOR]], [[XOR1]]
419 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[OR]], 1
420 ; CHECK-NEXT: ret i1 [[CMP]]
422 %xor = xor i64 %x1, %y1
423 %xor1 = xor i64 %x2, %y2
424 %or = or i64 %xor, %xor1
425 %cmp = icmp ne i64 %or, 1
429 ; negative test - xor multiuse
431 ; NB: This requires more than 1 iteration to simplify. After we
432 ; simplify `%cmp_1 = icmp eq i64 %xor, 0`, `%xor = xor i64 %x1, %y1`
433 ; has one use which allows for complete simplification (rooted on
434 ; `%or1 = or i1 %cmp, %cmp_1` so we don't end up adding it back).
435 define i1 @icmp_or_xor_2_3_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) "instcombine-no-verify-fixpoint" {
436 ; CHECK-LABEL: @icmp_or_xor_2_3_fail(
437 ; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
438 ; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
439 ; CHECK-NEXT: [[OR:%.*]] = or i64 [[XOR]], [[XOR1]]
440 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR]], 0
441 ; CHECK-NEXT: [[CMP_1:%.*]] = icmp eq i64 [[X1]], [[Y1]]
442 ; CHECK-NEXT: [[OR1:%.*]] = or i1 [[CMP]], [[CMP_1]]
443 ; CHECK-NEXT: ret i1 [[OR1]]
445 %xor = xor i64 %x1, %y1
446 %xor1 = xor i64 %x2, %y2
447 %or = or i64 %xor, %xor1
448 %cmp = icmp eq i64 %or, 0
449 %cmp_1 = icmp eq i64 %xor, 0
450 %or1 = or i1 %cmp, %cmp_1
454 ; negative test - xor multiuse
456 define i1 @icmp_or_xor_2_4_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) "instcombine-no-verify-fixpoint" {
457 ; CHECK-LABEL: @icmp_or_xor_2_4_fail(
458 ; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
459 ; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
460 ; CHECK-NEXT: [[OR:%.*]] = or i64 [[XOR]], [[XOR1]]
461 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR]], 0
462 ; CHECK-NEXT: [[CMP_1:%.*]] = icmp eq i64 [[X2]], [[Y2]]
463 ; CHECK-NEXT: [[OR1:%.*]] = or i1 [[CMP]], [[CMP_1]]
464 ; CHECK-NEXT: ret i1 [[OR1]]
466 %xor = xor i64 %x1, %y1
467 %xor1 = xor i64 %x2, %y2
468 %or = or i64 %xor, %xor1
469 %cmp = icmp eq i64 %or, 0
470 %cmp_1 = icmp eq i64 %xor1, 0
471 %or1 = or i1 %cmp, %cmp_1
475 define i1 @icmp_or_xor_3_1(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
476 ; CHECK-LABEL: @icmp_or_xor_3_1(
477 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[X1:%.*]], [[Y1:%.*]]
478 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[X2:%.*]], [[Y2:%.*]]
479 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP1]], [[TMP2]]
480 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[X3:%.*]], [[Y3:%.*]]
481 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP3]], [[TMP4]]
482 ; CHECK-NEXT: ret i1 [[CMP]]
484 %xor = xor i64 %x1, %y1
485 %xor1 = xor i64 %x2, %y2
486 %or = or i64 %xor, %xor1
487 %xor2 = xor i64 %x3, %y3
488 %or1 = or i64 %or, %xor2
489 %cmp = icmp eq i64 %or1, 0
493 ; negative test - and instead of or
495 define i1 @icmp_or_xor_3_2_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
496 ; CHECK-LABEL: @icmp_or_xor_3_2_fail(
497 ; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
498 ; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
499 ; CHECK-NEXT: [[AND:%.*]] = and i64 [[XOR]], [[XOR1]]
500 ; CHECK-NEXT: [[XOR2:%.*]] = xor i64 [[X3:%.*]], [[Y3:%.*]]
501 ; CHECK-NEXT: [[OR1:%.*]] = or i64 [[AND]], [[XOR2]]
502 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR1]], 0
503 ; CHECK-NEXT: ret i1 [[CMP]]
505 %xor = xor i64 %x1, %y1
506 %xor1 = xor i64 %x2, %y2
507 %and = and i64 %xor, %xor1
508 %xor2 = xor i64 %x3, %y3
509 %or1 = or i64 %and, %xor2
510 %cmp = icmp eq i64 %or1, 0
514 define i1 @icmp_or_xor_3_3(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
515 ; CHECK-LABEL: @icmp_or_xor_3_3(
516 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[X1:%.*]], [[Y1:%.*]]
517 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[X2:%.*]], [[Y2:%.*]]
518 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP1]], [[TMP2]]
519 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[X3:%.*]], [[Y3:%.*]]
520 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP3]], [[TMP4]]
521 ; CHECK-NEXT: ret i1 [[CMP]]
523 %xor = xor i64 %x1, %y1
524 %xor1 = xor i64 %x2, %y2
525 %or = or i64 %xor, %xor1
526 %xor2 = xor i64 %x3, %y3
527 %or1 = or i64 %xor2, %or
528 %cmp = icmp eq i64 %or1, 0
532 ; negative test - and instead of or
534 define i1 @icmp_or_xor_3_4_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
535 ; CHECK-LABEL: @icmp_or_xor_3_4_fail(
536 ; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
537 ; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
538 ; CHECK-NEXT: [[AND:%.*]] = and i64 [[XOR]], [[XOR1]]
539 ; CHECK-NEXT: [[XOR2:%.*]] = xor i64 [[X3:%.*]], [[Y3:%.*]]
540 ; CHECK-NEXT: [[OR1:%.*]] = or i64 [[XOR2]], [[AND]]
541 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR1]], 0
542 ; CHECK-NEXT: ret i1 [[CMP]]
544 %xor = xor i64 %x1, %y1
545 %xor1 = xor i64 %x2, %y2
546 %and = and i64 %xor, %xor1
547 %xor2 = xor i64 %x3, %y3
548 %or1 = or i64 %xor2, %and
549 %cmp = icmp eq i64 %or1, 0
553 define i1 @icmp_or_xor_4_1(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3, i64 %x4, i64 %y4) {
554 ; CHECK-LABEL: @icmp_or_xor_4_1(
555 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[X3:%.*]], [[Y3:%.*]]
556 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[X4:%.*]], [[Y4:%.*]]
557 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP1]], [[TMP2]]
558 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[X1:%.*]], [[Y1:%.*]]
559 ; CHECK-NEXT: [[TMP5:%.*]] = and i1 [[TMP3]], [[TMP4]]
560 ; CHECK-NEXT: [[TMP6:%.*]] = icmp eq i64 [[X2:%.*]], [[Y2:%.*]]
561 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP5]], [[TMP6]]
562 ; CHECK-NEXT: ret i1 [[CMP]]
564 %xor = xor i64 %x1, %y1
565 %xor1 = xor i64 %x2, %y2
566 %or = or i64 %xor, %xor1
567 %xor2 = xor i64 %x3, %y3
568 %xor3 = xor i64 %x4, %y4
569 %or1 = or i64 %xor2, %xor3
570 %or2 = or i64 %or, %or1
571 %cmp = icmp eq i64 %or2, 0
575 define i1 @icmp_or_xor_4_2(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3, i64 %x4, i64 %y4) {
576 ; CHECK-LABEL: @icmp_or_xor_4_2(
577 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[X1:%.*]], [[Y1:%.*]]
578 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[X2:%.*]], [[Y2:%.*]]
579 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP1]], [[TMP2]]
580 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[X3:%.*]], [[Y3:%.*]]
581 ; CHECK-NEXT: [[TMP5:%.*]] = and i1 [[TMP3]], [[TMP4]]
582 ; CHECK-NEXT: [[TMP6:%.*]] = icmp eq i64 [[X4:%.*]], [[Y4:%.*]]
583 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP5]], [[TMP6]]
584 ; CHECK-NEXT: ret i1 [[CMP]]
586 %xor = xor i64 %x1, %y1
587 %xor1 = xor i64 %x2, %y2
588 %or = or i64 %xor, %xor1
589 %xor2 = xor i64 %x3, %y3
590 %xor3 = xor i64 %x4, %y4
591 %or1 = or i64 %xor2, %xor3
592 %or2 = or i64 %or1, %or
593 %cmp = icmp eq i64 %or2, 0
597 define i1 @icmp_or_sub_2_eq(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
598 ; CHECK-LABEL: @icmp_or_sub_2_eq(
599 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[X1:%.*]], [[Y1:%.*]]
600 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[X2:%.*]], [[Y2:%.*]]
601 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP1]], [[TMP2]]
602 ; CHECK-NEXT: ret i1 [[CMP]]
604 %sub = sub i64 %x1, %y1
605 %sub1 = sub i64 %x2, %y2
606 %or = or i64 %sub, %sub1
607 %cmp = icmp eq i64 %or, 0
611 define i1 @icmp_or_sub_2_ne(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
612 ; CHECK-LABEL: @icmp_or_sub_2_ne(
613 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i64 [[X1:%.*]], [[Y1:%.*]]
614 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i64 [[X2:%.*]], [[Y2:%.*]]
615 ; CHECK-NEXT: [[CMP:%.*]] = or i1 [[TMP1]], [[TMP2]]
616 ; CHECK-NEXT: ret i1 [[CMP]]
618 %sub = sub i64 %x1, %y1
619 %sub1 = sub i64 %x2, %y2
620 %or = or i64 %sub, %sub1
621 %cmp = icmp ne i64 %or, 0
625 ; negative test - wrong cmp constant
627 define i1 @icmp_or_sub_2_eq_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
628 ; CHECK-LABEL: @icmp_or_sub_2_eq_fail(
629 ; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[X1:%.*]], [[Y1:%.*]]
630 ; CHECK-NEXT: [[SUB1:%.*]] = sub i64 [[X2:%.*]], [[Y2:%.*]]
631 ; CHECK-NEXT: [[OR:%.*]] = or i64 [[SUB]], [[SUB1]]
632 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR]], 1
633 ; CHECK-NEXT: ret i1 [[CMP]]
635 %sub = sub i64 %x1, %y1
636 %sub1 = sub i64 %x2, %y2
637 %or = or i64 %sub, %sub1
638 %cmp = icmp eq i64 %or, 1
642 ; negative test - wrong cmp constant
644 define i1 @icmp_or_sub_2_ne_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
645 ; CHECK-LABEL: @icmp_or_sub_2_ne_fail(
646 ; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[X1:%.*]], [[Y1:%.*]]
647 ; CHECK-NEXT: [[SUB1:%.*]] = sub i64 [[X2:%.*]], [[Y2:%.*]]
648 ; CHECK-NEXT: [[OR:%.*]] = or i64 [[SUB]], [[SUB1]]
649 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[OR]], 1
650 ; CHECK-NEXT: ret i1 [[CMP]]
652 %sub = sub i64 %x1, %y1
653 %sub1 = sub i64 %x2, %y2
654 %or = or i64 %sub, %sub1
655 %cmp = icmp ne i64 %or, 1
659 ; negative test - sub multiuse
661 define i1 @icmp_or_sub_2_3_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
662 ; CHECK-LABEL: @icmp_or_sub_2_3_fail(
663 ; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[X1:%.*]], [[Y1:%.*]]
664 ; CHECK-NEXT: [[SUB1:%.*]] = sub i64 [[X2:%.*]], [[Y2:%.*]]
665 ; CHECK-NEXT: [[OR:%.*]] = or i64 [[SUB]], [[SUB1]]
666 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR]], 0
667 ; CHECK-NEXT: [[CMP_1:%.*]] = icmp eq i64 [[SUB]], 1
668 ; CHECK-NEXT: [[OR1:%.*]] = or i1 [[CMP]], [[CMP_1]]
669 ; CHECK-NEXT: ret i1 [[OR1]]
671 %sub = sub i64 %x1, %y1
672 %sub1 = sub i64 %x2, %y2
673 %or = or i64 %sub, %sub1
674 %cmp = icmp eq i64 %or, 0
675 %cmp_1 = icmp eq i64 %sub, 1
676 %or1 = or i1 %cmp, %cmp_1
680 ; negative test - sub multiuse
682 define i1 @icmp_or_sub_2_4_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
683 ; CHECK-LABEL: @icmp_or_sub_2_4_fail(
684 ; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[X1:%.*]], [[Y1:%.*]]
685 ; CHECK-NEXT: [[SUB1:%.*]] = sub i64 [[X2:%.*]], [[Y2:%.*]]
686 ; CHECK-NEXT: [[OR:%.*]] = or i64 [[SUB]], [[SUB1]]
687 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR]], 0
688 ; CHECK-NEXT: [[CMP_1:%.*]] = icmp eq i64 [[SUB1]], 1
689 ; CHECK-NEXT: [[OR1:%.*]] = or i1 [[CMP]], [[CMP_1]]
690 ; CHECK-NEXT: ret i1 [[OR1]]
692 %sub = sub i64 %x1, %y1
693 %sub1 = sub i64 %x2, %y2
694 %or = or i64 %sub, %sub1
695 %cmp = icmp eq i64 %or, 0
696 %cmp_1 = icmp eq i64 %sub1, 1
697 %or1 = or i1 %cmp, %cmp_1
701 define i1 @icmp_or_sub_3_1(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
702 ; CHECK-LABEL: @icmp_or_sub_3_1(
703 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[X1:%.*]], [[Y1:%.*]]
704 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[X2:%.*]], [[Y2:%.*]]
705 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP1]], [[TMP2]]
706 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[X3:%.*]], [[Y3:%.*]]
707 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP3]], [[TMP4]]
708 ; CHECK-NEXT: ret i1 [[CMP]]
710 %sub = sub i64 %x1, %y1
711 %sub1 = sub i64 %x2, %y2
712 %or = or i64 %sub, %sub1
713 %sub2 = sub i64 %x3, %y3
714 %or1 = or i64 %or, %sub2
715 %cmp = icmp eq i64 %or1, 0
719 ; negative test - and instead of or
721 define i1 @icmp_or_sub_3_2_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
722 ; CHECK-LABEL: @icmp_or_sub_3_2_fail(
723 ; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[X1:%.*]], [[Y1:%.*]]
724 ; CHECK-NEXT: [[SUB1:%.*]] = sub i64 [[X2:%.*]], [[Y2:%.*]]
725 ; CHECK-NEXT: [[AND:%.*]] = and i64 [[SUB]], [[SUB1]]
726 ; CHECK-NEXT: [[SUB2:%.*]] = sub i64 [[X3:%.*]], [[Y3:%.*]]
727 ; CHECK-NEXT: [[OR1:%.*]] = or i64 [[AND]], [[SUB2]]
728 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR1]], 0
729 ; CHECK-NEXT: ret i1 [[CMP]]
731 %sub = sub i64 %x1, %y1
732 %sub1 = sub i64 %x2, %y2
733 %and = and i64 %sub, %sub1
734 %sub2 = sub i64 %x3, %y3
735 %or1 = or i64 %and, %sub2
736 %cmp = icmp eq i64 %or1, 0
740 define i1 @icmp_or_sub_3_3(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
741 ; CHECK-LABEL: @icmp_or_sub_3_3(
742 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[X1:%.*]], [[Y1:%.*]]
743 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[X2:%.*]], [[Y2:%.*]]
744 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP1]], [[TMP2]]
745 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[X3:%.*]], [[Y3:%.*]]
746 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP3]], [[TMP4]]
747 ; CHECK-NEXT: ret i1 [[CMP]]
749 %sub = sub i64 %x1, %y1
750 %sub1 = sub i64 %x2, %y2
751 %or = or i64 %sub, %sub1
752 %sub2 = sub i64 %x3, %y3
753 %or1 = or i64 %sub2, %or
754 %cmp = icmp eq i64 %or1, 0
758 ; negative test - and instead of or
760 define i1 @icmp_or_sub_3_4_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
761 ; CHECK-LABEL: @icmp_or_sub_3_4_fail(
762 ; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[X1:%.*]], [[Y1:%.*]]
763 ; CHECK-NEXT: [[SUB1:%.*]] = sub i64 [[X2:%.*]], [[Y2:%.*]]
764 ; CHECK-NEXT: [[AND:%.*]] = and i64 [[SUB]], [[SUB1]]
765 ; CHECK-NEXT: [[SUB2:%.*]] = sub i64 [[X3:%.*]], [[Y3:%.*]]
766 ; CHECK-NEXT: [[OR1:%.*]] = or i64 [[SUB2]], [[AND]]
767 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR1]], 0
768 ; CHECK-NEXT: ret i1 [[CMP]]
770 %sub = sub i64 %x1, %y1
771 %sub1 = sub i64 %x2, %y2
772 %and = and i64 %sub, %sub1
773 %sub2 = sub i64 %x3, %y3
774 %or1 = or i64 %sub2, %and
775 %cmp = icmp eq i64 %or1, 0
779 define i1 @icmp_or_sub_4_1(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3, i64 %x4, i64 %y4) {
780 ; CHECK-LABEL: @icmp_or_sub_4_1(
781 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[X3:%.*]], [[Y3:%.*]]
782 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[X4:%.*]], [[Y4:%.*]]
783 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP1]], [[TMP2]]
784 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[X1:%.*]], [[Y1:%.*]]
785 ; CHECK-NEXT: [[TMP5:%.*]] = and i1 [[TMP3]], [[TMP4]]
786 ; CHECK-NEXT: [[TMP6:%.*]] = icmp eq i64 [[X2:%.*]], [[Y2:%.*]]
787 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP5]], [[TMP6]]
788 ; CHECK-NEXT: ret i1 [[CMP]]
790 %sub = sub i64 %x1, %y1
791 %sub1 = sub i64 %x2, %y2
792 %or = or i64 %sub, %sub1
793 %sub2 = sub i64 %x3, %y3
794 %sub3 = sub i64 %x4, %y4
795 %or1 = or i64 %sub2, %sub3
796 %or2 = or i64 %or, %or1
797 %cmp = icmp eq i64 %or2, 0
801 define i1 @icmp_or_sub_4_2(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3, i64 %x4, i64 %y4) {
802 ; CHECK-LABEL: @icmp_or_sub_4_2(
803 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[X1:%.*]], [[Y1:%.*]]
804 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[X2:%.*]], [[Y2:%.*]]
805 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP1]], [[TMP2]]
806 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[X3:%.*]], [[Y3:%.*]]
807 ; CHECK-NEXT: [[TMP5:%.*]] = and i1 [[TMP3]], [[TMP4]]
808 ; CHECK-NEXT: [[TMP6:%.*]] = icmp eq i64 [[X4:%.*]], [[Y4:%.*]]
809 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP5]], [[TMP6]]
810 ; CHECK-NEXT: ret i1 [[CMP]]
812 %sub = sub i64 %x1, %y1
813 %sub1 = sub i64 %x2, %y2
814 %or = or i64 %sub, %sub1
815 %sub2 = sub i64 %x3, %y3
816 %sub3 = sub i64 %x4, %y4
817 %or1 = or i64 %sub2, %sub3
818 %or2 = or i64 %or1, %or
819 %cmp = icmp eq i64 %or2, 0
823 define i1 @icmp_or_xor_with_sub_2_eq(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
824 ; CHECK-LABEL: @icmp_or_xor_with_sub_2_eq(
825 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[X1:%.*]], [[Y1:%.*]]
826 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[X2:%.*]], [[Y2:%.*]]
827 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP1]], [[TMP2]]
828 ; CHECK-NEXT: ret i1 [[CMP]]
830 %xor = xor i64 %x1, %y1
831 %sub = sub i64 %x2, %y2
832 %or = or i64 %xor, %sub
833 %cmp = icmp eq i64 %or, 0
837 define i1 @icmp_or_xor_with_sub_2_ne(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
838 ; CHECK-LABEL: @icmp_or_xor_with_sub_2_ne(
839 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i64 [[X1:%.*]], [[Y1:%.*]]
840 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i64 [[X2:%.*]], [[Y2:%.*]]
841 ; CHECK-NEXT: [[CMP:%.*]] = or i1 [[TMP1]], [[TMP2]]
842 ; CHECK-NEXT: ret i1 [[CMP]]
844 %xor = xor i64 %x1, %y1
845 %sub = sub i64 %x2, %y2
846 %or = or i64 %xor, %sub
847 %cmp = icmp ne i64 %or, 0
851 define i1 @icmp_or_xor_with_sub_3_1(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
852 ; CHECK-LABEL: @icmp_or_xor_with_sub_3_1(
853 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[X1:%.*]], [[Y1:%.*]]
854 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[X2:%.*]], [[Y2:%.*]]
855 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP1]], [[TMP2]]
856 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[X3:%.*]], [[Y3:%.*]]
857 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP3]], [[TMP4]]
858 ; CHECK-NEXT: ret i1 [[CMP]]
860 %xor = xor i64 %x1, %y1
861 %xor1 = xor i64 %x2, %y2
862 %or = or i64 %xor, %xor1
863 %sub1 = sub i64 %x3, %y3
864 %or1 = or i64 %or, %sub1
865 %cmp = icmp eq i64 %or1, 0
869 define i1 @icmp_or_xor_with_sub_3_2(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
870 ; CHECK-LABEL: @icmp_or_xor_with_sub_3_2(
871 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[X1:%.*]], [[Y1:%.*]]
872 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[X2:%.*]], [[Y2:%.*]]
873 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP1]], [[TMP2]]
874 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[X3:%.*]], [[Y3:%.*]]
875 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP3]], [[TMP4]]
876 ; CHECK-NEXT: ret i1 [[CMP]]
878 %xor = xor i64 %x1, %y1
879 %sub = sub i64 %x2, %y2
880 %or = or i64 %xor, %sub
881 %xor1 = xor i64 %x3, %y3
882 %or1 = or i64 %or, %xor1
883 %cmp = icmp eq i64 %or1, 0
887 define i1 @icmp_or_xor_with_sub_3_3(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
888 ; CHECK-LABEL: @icmp_or_xor_with_sub_3_3(
889 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[X1:%.*]], [[Y1:%.*]]
890 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[X2:%.*]], [[Y2:%.*]]
891 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP1]], [[TMP2]]
892 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[X3:%.*]], [[Y3:%.*]]
893 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP3]], [[TMP4]]
894 ; CHECK-NEXT: ret i1 [[CMP]]
896 %xor = xor i64 %x1, %y1
897 %sub = sub i64 %x2, %y2
898 %or = or i64 %xor, %sub
899 %sub1 = sub i64 %x3, %y3
900 %or1 = or i64 %or, %sub1
901 %cmp = icmp eq i64 %or1, 0
905 define i1 @icmp_or_xor_with_sub_3_4(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
906 ; CHECK-LABEL: @icmp_or_xor_with_sub_3_4(
907 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[X1:%.*]], [[Y1:%.*]]
908 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[X2:%.*]], [[Y2:%.*]]
909 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP1]], [[TMP2]]
910 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[X3:%.*]], [[Y3:%.*]]
911 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP3]], [[TMP4]]
912 ; CHECK-NEXT: ret i1 [[CMP]]
914 %sub = sub i64 %x1, %y1
915 %xor = xor i64 %x2, %y2
916 %or = or i64 %sub, %xor
917 %xor1 = xor i64 %x3, %y3
918 %or1 = or i64 %or, %xor1
919 %cmp = icmp eq i64 %or1, 0
923 define i1 @icmp_or_xor_with_sub_3_5(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
924 ; CHECK-LABEL: @icmp_or_xor_with_sub_3_5(
925 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[X1:%.*]], [[Y1:%.*]]
926 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[X2:%.*]], [[Y2:%.*]]
927 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP1]], [[TMP2]]
928 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[X3:%.*]], [[Y3:%.*]]
929 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP3]], [[TMP4]]
930 ; CHECK-NEXT: ret i1 [[CMP]]
932 %sub = sub i64 %x1, %y1
933 %xor = xor i64 %x2, %y2
934 %or = or i64 %sub, %xor
935 %sub1 = sub i64 %x3, %y3
936 %or1 = or i64 %or, %sub1
937 %cmp = icmp eq i64 %or1, 0
941 define i1 @icmp_or_xor_with_sub_3_6(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
942 ; CHECK-LABEL: @icmp_or_xor_with_sub_3_6(
943 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[X1:%.*]], [[Y1:%.*]]
944 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[X2:%.*]], [[Y2:%.*]]
945 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP1]], [[TMP2]]
946 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[X3:%.*]], [[Y3:%.*]]
947 ; CHECK-NEXT: [[CMP:%.*]] = and i1 [[TMP3]], [[TMP4]]
948 ; CHECK-NEXT: ret i1 [[CMP]]
950 %sub = sub i64 %x1, %y1
951 %sub1 = sub i64 %x2, %y2
952 %or = or i64 %sub, %sub1
953 %xor = xor i64 %x3, %y3
954 %or1 = or i64 %or, %xor
955 %cmp = icmp eq i64 %or1, 0
960 define i1 @or_disjoint_with_constants(i8 %x) {
961 ; CHECK-LABEL: @or_disjoint_with_constants(
962 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[X:%.*]], 18
963 ; CHECK-NEXT: ret i1 [[CMP]]
965 %or = or disjoint i8 %x, 1
966 %cmp = icmp eq i8 %or, 19
971 define i1 @or_disjoint_with_constants2(i8 %x) {
972 ; CHECK-LABEL: @or_disjoint_with_constants2(
973 ; CHECK-NEXT: [[OR:%.*]] = or disjoint i8 [[X:%.*]], 5
974 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 [[X]], 66
975 ; CHECK-NEXT: call void @use(i8 [[OR]])
976 ; CHECK-NEXT: ret i1 [[CMP]]
978 %or = or disjoint i8 %x, 5
979 %cmp = icmp ne i8 %or, 71
980 call void @use(i8 %or)
985 define i1 @or_disjoint_with_constants_fail_missing_const1(i8 %x, i8 %y) {
986 ; CHECK-LABEL: @or_disjoint_with_constants_fail_missing_const1(
987 ; CHECK-NEXT: [[OR:%.*]] = or disjoint i8 [[X:%.*]], [[Y:%.*]]
988 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[OR]], 19
989 ; CHECK-NEXT: ret i1 [[CMP]]
991 %or = or disjoint i8 %x, %y
992 %cmp = icmp eq i8 %or, 19
996 define i1 @or_disjoint_with_constants_fail_missing_const2(i8 %x, i8 %y) {
997 ; CHECK-LABEL: @or_disjoint_with_constants_fail_missing_const2(
998 ; CHECK-NEXT: [[OR:%.*]] = or disjoint i8 [[X:%.*]], 19
999 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[OR]], [[Y:%.*]]
1000 ; CHECK-NEXT: ret i1 [[CMP]]
1002 %or = or disjoint i8 %x, 19
1003 %cmp = icmp eq i8 %or, %y