1 ; This test makes sure that these instructions are properly eliminated.
4 ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep 'xor '
9 %B = xor bool %A, false
18 bool %test2(bool %A) {
28 int %test4(int %A) { ; A ^ ~A == -1
29 %NotA = xor int -1, %A
30 %B = xor int %A, %NotA
34 uint %test5(uint %A) { ; (A|B)^B == A & (~B)
36 %r = xor uint %t1, 123
40 ubyte %test6(ubyte %A) {
46 ; (A & C1)^(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0
47 int %test7(int %A, int %B) {
51 %C1 = xor int %A1, %B1
55 ubyte %test8(bool %c) {
56 %d = xor bool %c, true ; invert the condition
57 br bool %d, label %True, label %False
64 bool %test9(ubyte %A) {
65 %B = xor ubyte %A, 123 ; xor can be eliminated
66 %C = seteq ubyte %B, 34
70 ubyte %test10(ubyte %A) {
72 %C = xor ubyte %B, 4 ; transform into an OR
76 ubyte %test11(ubyte %A) {
78 %C = xor ubyte %B, 4 ; transform into an AND
82 bool %test12(ubyte %A) {
84 %c = setne ubyte %B, 0
88 bool %test13(ubyte %A, ubyte %B) {
89 %C = setlt ubyte %A, %B
90 %D = setgt ubyte %A, %B
91 %E = xor bool %C, %D ; E = setne %A, %B
95 bool %test14(ubyte %A, ubyte %B) {
96 %C = seteq ubyte %A, %B
97 %D = setne ubyte %B, %A
98 %E = xor bool %C, %D ; E = true
102 uint %test15(uint %A) { ; ~(X-1) == -X
103 %B = add uint %A, 4294967295
104 %C = xor uint %B, 4294967295
108 uint %test16(uint %A) { ; ~(X+c) == (-c-1)-X
109 %B = add uint %A, 123 ; A generalization of the previous case
110 %C = xor uint %B, 4294967295
114 uint %test17(uint %A) { ; ~(c-X) == X-(c-1) == X+(-c+1)
115 %B = sub uint 123, %A
116 %C = xor uint %B, 4294967295