1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -instcombine < %s | FileCheck %s
4 ; X | ~(X | Y) --> X | ~Y
6 define i32 @test1(i32 %x, i32 %y) {
8 ; CHECK-NEXT: [[Y_NOT:%.*]] = xor i32 [[Y:%.*]], -1
9 ; CHECK-NEXT: [[Z:%.*]] = or i32 [[Y_NOT]], [[X:%.*]]
10 ; CHECK-NEXT: ret i32 [[Z]]
13 %not = xor i32 %or, -1
18 ; Commute (rename) the inner 'or' operands:
19 ; Y | ~(X | Y) --> ~X | Y
21 define i32 @test2(i32 %x, i32 %y) {
22 ; CHECK-LABEL: @test2(
23 ; CHECK-NEXT: [[X_NOT:%.*]] = xor i32 [[X:%.*]], -1
24 ; CHECK-NEXT: [[Z:%.*]] = or i32 [[X_NOT]], [[Y:%.*]]
25 ; CHECK-NEXT: ret i32 [[Z]]
28 %not = xor i32 %or, -1
33 ; X | ~(X ^ Y) --> X | ~Y
35 define i32 @test3(i32 %x, i32 %y) {
36 ; CHECK-LABEL: @test3(
37 ; CHECK-NEXT: [[Y_NOT:%.*]] = xor i32 [[Y:%.*]], -1
38 ; CHECK-NEXT: [[Z:%.*]] = or i32 [[Y_NOT]], [[X:%.*]]
39 ; CHECK-NEXT: ret i32 [[Z]]
42 %not = xor i32 %xor, -1
47 ; Commute (rename) the 'xor' operands:
48 ; Y | ~(X ^ Y) --> ~X | Y
50 define i32 @test4(i32 %x, i32 %y) {
51 ; CHECK-LABEL: @test4(
52 ; CHECK-NEXT: [[X_NOT:%.*]] = xor i32 [[X:%.*]], -1
53 ; CHECK-NEXT: [[Z:%.*]] = or i32 [[X_NOT]], [[Y:%.*]]
54 ; CHECK-NEXT: ret i32 [[Z]]
57 %not = xor i32 %xor, -1
62 ; (X ^ Y) | ~X --> ~(X & Y)
64 define i32 @test5(i32 %x, i32 %y) {
65 ; CHECK-LABEL: @test5(
66 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], [[Y:%.*]]
67 ; CHECK-NEXT: [[Z:%.*]] = xor i32 [[TMP1]], -1
68 ; CHECK-NEXT: ret i32 [[Z]]
71 %notx = xor i32 %x, -1
72 %z = or i32 %xor, %notx
76 ; Commute the 'or' operands
77 ; ~X | (X ^ Y) --> ~(X & Y)
79 define <2 x i4> @test5_commuted(<2 x i4> %x, <2 x i4> %y) {
80 ; CHECK-LABEL: @test5_commuted(
81 ; CHECK-NEXT: [[TMP1:%.*]] = and <2 x i4> [[X:%.*]], [[Y:%.*]]
82 ; CHECK-NEXT: [[Z:%.*]] = xor <2 x i4> [[TMP1]], <i4 -1, i4 -1>
83 ; CHECK-NEXT: ret <2 x i4> [[Z]]
85 %xor = xor <2 x i4> %x, %y
86 %notx = xor <2 x i4> %x, <i4 -1, i4 -1>
87 %z = or <2 x i4> %notx, %xor
91 ; Commute the inner 'xor' operands
92 ; (Y ^ X) | ~X --> ~(Y & X)
94 define i64 @test5_commuted_x_y(i64 %x, i64 %y) {
95 ; CHECK-LABEL: @test5_commuted_x_y(
96 ; CHECK-NEXT: [[TMP1:%.*]] = and i64 [[Y:%.*]], [[X:%.*]]
97 ; CHECK-NEXT: [[Z:%.*]] = xor i64 [[TMP1]], -1
98 ; CHECK-NEXT: ret i64 [[Z]]
100 %xor = xor i64 %y, %x
101 %notx = xor i64 %x, -1
102 %z = or i64 %xor, %notx
107 define i8 @test5_extra_use_not(i8 %x, i8 %y, i8* %dst) {
108 ; CHECK-LABEL: @test5_extra_use_not(
109 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
110 ; CHECK-NEXT: store i8 [[NOTX]], i8* [[DST:%.*]], align 1
111 ; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[X]], [[Y:%.*]]
112 ; CHECK-NEXT: [[Z:%.*]] = xor i8 [[TMP1]], -1
113 ; CHECK-NEXT: ret i8 [[Z]]
116 %notx = xor i8 %x, -1
117 store i8 %notx, i8* %dst
118 %z = or i8 %notx, %xor
123 define i65 @test5_extra_use_xor(i65 %x, i65 %y, i65* %dst) {
124 ; CHECK-LABEL: @test5_extra_use_xor(
125 ; CHECK-NEXT: [[XOR:%.*]] = xor i65 [[X:%.*]], [[Y:%.*]]
126 ; CHECK-NEXT: store i65 [[XOR]], i65* [[DST:%.*]], align 4
127 ; CHECK-NEXT: [[TMP1:%.*]] = and i65 [[X]], [[Y]]
128 ; CHECK-NEXT: [[Z:%.*]] = xor i65 [[TMP1]], -1
129 ; CHECK-NEXT: ret i65 [[Z]]
131 %xor = xor i65 %x, %y
132 store i65 %xor, i65* %dst
133 %notx = xor i65 %x, -1
134 %z = or i65 %notx, %xor
138 define i16 @test5_extra_use_not_xor(i16 %x, i16 %y, i16* %dst_not, i16* %dst_xor) {
139 ; CHECK-LABEL: @test5_extra_use_not_xor(
140 ; CHECK-NEXT: [[XOR:%.*]] = xor i16 [[X:%.*]], [[Y:%.*]]
141 ; CHECK-NEXT: store i16 [[XOR]], i16* [[DST_XOR:%.*]], align 2
142 ; CHECK-NEXT: [[NOTX:%.*]] = xor i16 [[X]], -1
143 ; CHECK-NEXT: store i16 [[NOTX]], i16* [[DST_NOT:%.*]], align 2
144 ; CHECK-NEXT: [[Z:%.*]] = or i16 [[XOR]], [[NOTX]]
145 ; CHECK-NEXT: ret i16 [[Z]]
147 %xor = xor i16 %x, %y
148 store i16 %xor, i16* %dst_xor
149 %notx = xor i16 %x, -1
150 store i16 %notx, i16* %dst_not
151 %z = or i16 %notx, %xor
155 define i32 @test7(i32 %x, i32 %y) {
156 ; CHECK-LABEL: @test7(
157 ; CHECK-NEXT: [[Z:%.*]] = or i32 [[X:%.*]], [[Y:%.*]]
158 ; CHECK-NEXT: ret i32 [[Z]]
160 %xor = xor i32 %x, %y
165 define i32 @test8(i32 %x, i32 %y) {
166 ; CHECK-LABEL: @test8(
167 ; CHECK-NEXT: [[X_NOT:%.*]] = xor i32 [[X:%.*]], -1
168 ; CHECK-NEXT: [[Z:%.*]] = or i32 [[X_NOT]], [[Y:%.*]]
169 ; CHECK-NEXT: ret i32 [[Z]]
171 %not = xor i32 %y, -1
172 %xor = xor i32 %x, %not
177 define i32 @test9(i32 %x, i32 %y) {
178 ; CHECK-LABEL: @test9(
179 ; CHECK-NEXT: [[Y_NOT:%.*]] = xor i32 [[Y:%.*]], -1
180 ; CHECK-NEXT: [[Z:%.*]] = or i32 [[Y_NOT]], [[X:%.*]]
181 ; CHECK-NEXT: ret i32 [[Z]]
183 %not = xor i32 %x, -1
184 %xor = xor i32 %not, %y
189 ; (A ^ B) | (~A ^ B) --> -1
191 define i32 @test10(i32 %A, i32 %B) {
192 ; CHECK-LABEL: @test10(
193 ; CHECK-NEXT: [[XOR1:%.*]] = xor i32 [[B:%.*]], [[A:%.*]]
194 ; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[A]], [[B]]
195 ; CHECK-NEXT: [[XOR2:%.*]] = xor i32 [[TMP1]], -1
196 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[XOR1]], [[XOR2]]
197 ; CHECK-NEXT: ret i32 [[OR]]
199 %xor1 = xor i32 %B, %A
200 %not = xor i32 %A, -1
201 %xor2 = xor i32 %not, %B
202 %or = or i32 %xor1, %xor2
206 define i32 @test10_commuted(i32 %A, i32 %B) {
207 ; CHECK-LABEL: @test10_commuted(
208 ; CHECK-NEXT: [[XOR1:%.*]] = xor i32 [[B:%.*]], [[A:%.*]]
209 ; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[A]], [[B]]
210 ; CHECK-NEXT: [[XOR2:%.*]] = xor i32 [[TMP1]], -1
211 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[XOR1]], [[XOR2]]
212 ; CHECK-NEXT: ret i32 [[OR]]
214 %xor1 = xor i32 %B, %A
215 %not = xor i32 %A, -1
216 %xor2 = xor i32 %not, %B
217 %or = or i32 %xor2, %xor1
221 define i32 @test10_extrause(i32 %A, i32 %B, i32* %dst) {
222 ; CHECK-LABEL: @test10_extrause(
223 ; CHECK-NEXT: [[NOT:%.*]] = xor i32 [[A:%.*]], -1
224 ; CHECK-NEXT: store i32 [[NOT]], i32* [[DST:%.*]], align 4
225 ; CHECK-NEXT: ret i32 -1
227 %xor1 = xor i32 %B, %A
228 %not = xor i32 %A, -1
229 store i32 %not, i32* %dst
230 %xor2 = xor i32 %not, %B
231 %or = or i32 %xor1, %xor2
235 define i32 @test10_commuted_extrause(i32 %A, i32 %B, i32* %dst) {
236 ; CHECK-LABEL: @test10_commuted_extrause(
237 ; CHECK-NEXT: [[NOT:%.*]] = xor i32 [[A:%.*]], -1
238 ; CHECK-NEXT: store i32 [[NOT]], i32* [[DST:%.*]], align 4
239 ; CHECK-NEXT: ret i32 -1
241 %xor1 = xor i32 %B, %A
242 %not = xor i32 %A, -1
243 store i32 %not, i32* %dst
244 %xor2 = xor i32 %not, %B
245 %or = or i32 %xor2, %xor1
249 ; (A ^ B) | ~(A ^ B) --> -1
250 define i32 @test10_canonical(i32 %A, i32 %B) {
251 ; CHECK-LABEL: @test10_canonical(
252 ; CHECK-NEXT: [[XOR1:%.*]] = xor i32 [[B:%.*]], [[A:%.*]]
253 ; CHECK-NEXT: [[XOR2:%.*]] = xor i32 [[A]], [[B]]
254 ; CHECK-NEXT: [[NOT:%.*]] = xor i32 [[XOR2]], -1
255 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[XOR1]], [[NOT]]
256 ; CHECK-NEXT: ret i32 [[OR]]
258 %xor1 = xor i32 %B, %A
259 %xor2 = xor i32 %A, %B
260 %not = xor i32 %xor2, -1
261 %or = or i32 %xor1, %not
265 ; (x | y) & ((~x) ^ y) -> (x & y)
266 define i32 @test11(i32 %x, i32 %y) {
267 ; CHECK-LABEL: @test11(
268 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[Y:%.*]]
269 ; CHECK-NEXT: ret i32 [[AND]]
272 %neg = xor i32 %x, -1
273 %xor = xor i32 %neg, %y
274 %and = and i32 %or, %xor
278 ; ((~x) ^ y) & (x | y) -> (x & y)
279 define i32 @test12(i32 %x, i32 %y) {
280 ; CHECK-LABEL: @test12(
281 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[Y:%.*]]
282 ; CHECK-NEXT: ret i32 [[AND]]
284 %neg = xor i32 %x, -1
285 %xor = xor i32 %neg, %y
287 %and = and i32 %xor, %or
291 define i32 @test12_commuted(i32 %x, i32 %y) {
292 ; CHECK-LABEL: @test12_commuted(
293 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[Y:%.*]]
294 ; CHECK-NEXT: ret i32 [[AND]]
296 %neg = xor i32 %x, -1
297 %xor = xor i32 %neg, %y
299 %and = and i32 %xor, %or
303 ; ((x | y) ^ (x ^ y)) -> (x & y)
304 define i32 @test13(i32 %x, i32 %y) {
305 ; CHECK-LABEL: @test13(
306 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[Y:%.*]], [[X:%.*]]
307 ; CHECK-NEXT: ret i32 [[TMP1]]
315 ; ((x | ~y) ^ (~x | y)) -> x ^ y
316 define i32 @test14(i32 %x, i32 %y) {
317 ; CHECK-LABEL: @test14(
318 ; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
319 ; CHECK-NEXT: ret i32 [[XOR]]
321 %noty = xor i32 %y, -1
322 %notx = xor i32 %x, -1
323 %or1 = or i32 %x, %noty
324 %or2 = or i32 %notx, %y
325 %xor = xor i32 %or1, %or2
329 define i32 @test14_commuted(i32 %x, i32 %y) {
330 ; CHECK-LABEL: @test14_commuted(
331 ; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
332 ; CHECK-NEXT: ret i32 [[XOR]]
334 %noty = xor i32 %y, -1
335 %notx = xor i32 %x, -1
336 %or1 = or i32 %noty, %x
337 %or2 = or i32 %notx, %y
338 %xor = xor i32 %or1, %or2
342 ; ((x & ~y) ^ (~x & y)) -> x ^ y
343 define i32 @test15(i32 %x, i32 %y) {
344 ; CHECK-LABEL: @test15(
345 ; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
346 ; CHECK-NEXT: ret i32 [[XOR]]
348 %noty = xor i32 %y, -1
349 %notx = xor i32 %x, -1
350 %and1 = and i32 %x, %noty
351 %and2 = and i32 %notx, %y
352 %xor = xor i32 %and1, %and2
356 define i32 @test15_commuted(i32 %x, i32 %y) {
357 ; CHECK-LABEL: @test15_commuted(
358 ; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
359 ; CHECK-NEXT: ret i32 [[XOR]]
361 %noty = xor i32 %y, -1
362 %notx = xor i32 %x, -1
363 %and1 = and i32 %noty, %x
364 %and2 = and i32 %notx, %y
365 %xor = xor i32 %and1, %and2
369 ; ((a ^ b) & C1) | (b & C2) -> (a & C1) ^ b iff C1 == ~C2
371 define i32 @or_and_xor_not_constant_commute0(i32 %a, i32 %b) {
372 ; CHECK-LABEL: @or_and_xor_not_constant_commute0(
373 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[A:%.*]], 1
374 ; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[TMP1]], [[B:%.*]]
375 ; CHECK-NEXT: ret i32 [[XOR]]
378 %and1 = and i32 %or, 1
379 %and2 = and i32 %b, -2
380 %xor = or i32 %and1, %and2
384 define i9 @or_and_xor_not_constant_commute1(i9 %a, i9 %b) {
385 ; CHECK-LABEL: @or_and_xor_not_constant_commute1(
386 ; CHECK-NEXT: [[TMP1:%.*]] = and i9 [[A:%.*]], 42
387 ; CHECK-NEXT: [[XOR:%.*]] = xor i9 [[TMP1]], [[B:%.*]]
388 ; CHECK-NEXT: ret i9 [[XOR]]
391 %and1 = and i9 %or, 42
392 %and2 = and i9 %b, -43
393 %xor = or i9 %and1, %and2
397 define <2 x i9> @or_and_xor_not_constant_commute2_splat(<2 x i9> %a, <2 x i9> %b) {
398 ; CHECK-LABEL: @or_and_xor_not_constant_commute2_splat(
399 ; CHECK-NEXT: [[TMP1:%.*]] = and <2 x i9> [[A:%.*]], <i9 42, i9 42>
400 ; CHECK-NEXT: [[XOR:%.*]] = xor <2 x i9> [[TMP1]], [[B:%.*]]
401 ; CHECK-NEXT: ret <2 x i9> [[XOR]]
403 %or = xor <2 x i9> %b, %a
404 %and1 = and <2 x i9> %or, <i9 42, i9 42>
405 %and2 = and <2 x i9> %b, <i9 -43, i9 -43>
406 %xor = or <2 x i9> %and2, %and1
410 define <2 x i9> @or_and_xor_not_constant_commute3_splat(<2 x i9> %a, <2 x i9> %b) {
411 ; CHECK-LABEL: @or_and_xor_not_constant_commute3_splat(
412 ; CHECK-NEXT: [[TMP1:%.*]] = and <2 x i9> [[A:%.*]], <i9 42, i9 42>
413 ; CHECK-NEXT: [[XOR:%.*]] = xor <2 x i9> [[TMP1]], [[B:%.*]]
414 ; CHECK-NEXT: ret <2 x i9> [[XOR]]
416 %or = xor <2 x i9> %a, %b
417 %and1 = and <2 x i9> %or, <i9 42, i9 42>
418 %and2 = and <2 x i9> %b, <i9 -43, i9 -43>
419 %xor = or <2 x i9> %and2, %and1
423 define i8 @not_or(i8 %x) {
424 ; CHECK-LABEL: @not_or(
425 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
426 ; CHECK-NEXT: [[OR:%.*]] = or i8 [[NOTX]], 7
427 ; CHECK-NEXT: ret i8 [[OR]]
429 %notx = xor i8 %x, -1
434 define i8 @not_or_xor(i8 %x) {
435 ; CHECK-LABEL: @not_or_xor(
436 ; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[X:%.*]], -8
437 ; CHECK-NEXT: [[XOR:%.*]] = xor i8 [[TMP1]], -13
438 ; CHECK-NEXT: ret i8 [[XOR]]
440 %notx = xor i8 %x, -1
442 %xor = xor i8 %or, 12
446 define i8 @xor_or(i8 %x) {
447 ; CHECK-LABEL: @xor_or(
448 ; CHECK-NEXT: [[TMP1:%.*]] = or i8 [[X:%.*]], 7
449 ; CHECK-NEXT: [[OR:%.*]] = xor i8 [[TMP1]], 32
450 ; CHECK-NEXT: ret i8 [[OR]]
457 define i8 @xor_or2(i8 %x) {
458 ; CHECK-LABEL: @xor_or2(
459 ; CHECK-NEXT: [[TMP1:%.*]] = or i8 [[X:%.*]], 7
460 ; CHECK-NEXT: [[OR:%.*]] = xor i8 [[TMP1]], 32
461 ; CHECK-NEXT: ret i8 [[OR]]
468 define i8 @xor_or_xor(i8 %x) {
469 ; CHECK-LABEL: @xor_or_xor(
470 ; CHECK-NEXT: [[TMP1:%.*]] = or i8 [[X:%.*]], 7
471 ; CHECK-NEXT: [[XOR2:%.*]] = xor i8 [[TMP1]], 44
472 ; CHECK-NEXT: ret i8 [[XOR2]]
474 %xor1 = xor i8 %x, 33
476 %xor2 = xor i8 %or, 12
480 define i8 @or_xor_or(i8 %x) {
481 ; CHECK-LABEL: @or_xor_or(
482 ; CHECK-NEXT: [[TMP1:%.*]] = or i8 [[X:%.*]], 39
483 ; CHECK-NEXT: [[OR2:%.*]] = xor i8 [[TMP1]], 8
484 ; CHECK-NEXT: ret i8 [[OR2]]
487 %xor = xor i8 %or1, 12
492 define i8 @test17(i8 %A, i8 %B) {
493 ; CHECK-LABEL: @test17(
494 ; CHECK-NEXT: [[XOR1:%.*]] = xor i8 [[B:%.*]], [[A:%.*]]
495 ; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[A]], [[B]]
496 ; CHECK-NEXT: [[XOR2:%.*]] = xor i8 [[TMP1]], 33
497 ; CHECK-NEXT: [[OR:%.*]] = or i8 [[XOR1]], [[XOR2]]
498 ; CHECK-NEXT: [[RES:%.*]] = mul i8 [[OR]], [[XOR2]]
499 ; CHECK-NEXT: ret i8 [[RES]]
501 %xor1 = xor i8 %B, %A
503 %xor2 = xor i8 %not, %B
504 %or = or i8 %xor1, %xor2
505 %res = mul i8 %or, %xor2 ; to increase the use count for the xor
509 define i8 @test18(i8 %A, i8 %B) {
510 ; CHECK-LABEL: @test18(
511 ; CHECK-NEXT: [[XOR1:%.*]] = xor i8 [[B:%.*]], [[A:%.*]]
512 ; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[A]], [[B]]
513 ; CHECK-NEXT: [[XOR2:%.*]] = xor i8 [[TMP1]], 33
514 ; CHECK-NEXT: [[OR:%.*]] = or i8 [[XOR2]], [[XOR1]]
515 ; CHECK-NEXT: [[RES:%.*]] = mul i8 [[OR]], [[XOR2]]
516 ; CHECK-NEXT: ret i8 [[RES]]
518 %xor1 = xor i8 %B, %A
520 %xor2 = xor i8 %not, %B
521 %or = or i8 %xor2, %xor1
522 %res = mul i8 %or, %xor2 ; to increase the use count for the xor
526 ; ((x | y) ^ (~x | ~y)) -> ~(x ^ y)
527 define i32 @test19(i32 %x, i32 %y) {
528 ; CHECK-LABEL: @test19(
529 ; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
530 ; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[TMP1]], -1
531 ; CHECK-NEXT: ret i32 [[XOR]]
533 %noty = xor i32 %y, -1
534 %notx = xor i32 %x, -1
536 %or2 = or i32 %notx, %noty
537 %xor = xor i32 %or1, %or2
541 ; ((x | y) ^ (~y | ~x)) -> ~(x ^ y)
542 define i32 @test20(i32 %x, i32 %y) {
543 ; CHECK-LABEL: @test20(
544 ; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
545 ; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[TMP1]], -1
546 ; CHECK-NEXT: ret i32 [[XOR]]
548 %noty = xor i32 %y, -1
549 %notx = xor i32 %x, -1
551 %or2 = or i32 %noty, %notx
552 %xor = xor i32 %or1, %or2
556 ; ((~x | ~y) ^ (x | y)) -> ~(x ^ y)
557 define i32 @test21(i32 %x, i32 %y) {
558 ; CHECK-LABEL: @test21(
559 ; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
560 ; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[TMP1]], -1
561 ; CHECK-NEXT: ret i32 [[XOR]]
563 %noty = xor i32 %y, -1
564 %notx = xor i32 %x, -1
565 %or1 = or i32 %notx, %noty
567 %xor = xor i32 %or1, %or2
571 ; ((~x | ~y) ^ (y | x)) -> ~(x ^ y)
572 define i32 @test22(i32 %x, i32 %y) {
573 ; CHECK-LABEL: @test22(
574 ; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[Y:%.*]], [[X:%.*]]
575 ; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[TMP1]], -1
576 ; CHECK-NEXT: ret i32 [[XOR]]
578 %noty = xor i32 %y, -1
579 %notx = xor i32 %x, -1
580 %or1 = or i32 %notx, %noty
582 %xor = xor i32 %or1, %or2
586 ; (X ^ C1) | C2 --> (X | C2) ^ (C1&~C2)
587 define i8 @test23(i8 %A) {
588 ; CHECK-LABEL: @test23(
589 ; CHECK-NEXT: ret i8 -1
598 define i8 @test23v(<2 x i8> %A) {
599 ; CHECK-LABEL: @test23v(
600 ; CHECK-NEXT: ret i8 -1
602 %B = or <2 x i8> %A, <i8 -2, i8 0>
603 %CV = xor <2 x i8> %B, <i8 13, i8 13>
604 %C = extractelement <2 x i8> %CV, i32 0
610 ; ~(a | b) | (~a & b);
611 define i32 @PR45977_f1(i32 %a, i32 %b) {
612 ; CHECK-LABEL: @PR45977_f1(
613 ; CHECK-NEXT: [[NOT:%.*]] = xor i32 [[A:%.*]], -1
614 ; CHECK-NEXT: ret i32 [[NOT]]
616 %not = xor i32 %a, -1
617 %andnot = and i32 %not, %b
619 %notor = xor i32 %or, -1
620 %res = or i32 %notor, %andnot
625 define i32 @PR45977_f2(i32 %a, i32 %b) {
626 ; CHECK-LABEL: @PR45977_f2(
627 ; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[A:%.*]], -1
628 ; CHECK-NEXT: ret i32 [[TMP1]]
631 %not = xor i32 %b, -1
632 %ornot = or i32 %a, %not
633 %res = xor i32 %or, %ornot