1 ; This test makes sure that these instructions are properly eliminated.
3 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \
12 bool %test0(bool %A) {
13 %B = xor bool %A, false
22 bool %test2(bool %A) {
32 int %test4(int %A) { ; A ^ ~A == -1
33 %NotA = xor int -1, %A
34 %B = xor int %A, %NotA
38 uint %test5(uint %A) { ; (A|B)^B == A & (~B)
40 %r = xor uint %t1, 123
44 ubyte %test6(ubyte %A) {
50 ; (A & C1)^(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0
51 int %test7(int %A, int %B) {
55 %C1 = xor int %A1, %B1
59 ubyte %test8(bool %c) {
60 %d = xor bool %c, true ; invert the condition
61 br bool %d, label %True, label %False
68 bool %test9(ubyte %A) {
69 %B = xor ubyte %A, 123 ; xor can be eliminated
70 %C = seteq ubyte %B, 34
74 ubyte %test10(ubyte %A) {
76 %C = xor ubyte %B, 4 ; transform into an OR
80 ubyte %test11(ubyte %A) {
82 %C = xor ubyte %B, 4 ; transform into an AND
86 bool %test12(ubyte %A) {
88 %c = setne ubyte %B, 0
92 bool %test13(ubyte %A, ubyte %B) {
93 %C = setlt ubyte %A, %B
94 %D = setgt ubyte %A, %B
95 %E = xor bool %C, %D ; E = setne %A, %B
99 bool %test14(ubyte %A, ubyte %B) {
100 %C = seteq ubyte %A, %B
101 %D = setne ubyte %B, %A
102 %E = xor bool %C, %D ; E = true
106 uint %test15(uint %A) { ; ~(X-1) == -X
107 %B = add uint %A, 4294967295
108 %C = xor uint %B, 4294967295
112 uint %test16(uint %A) { ; ~(X+c) == (-c-1)-X
113 %B = add uint %A, 123 ; A generalization of the previous case
114 %C = xor uint %B, 4294967295
118 uint %test17(uint %A) { ; ~(c-X) == X-(c-1) == X+(-c+1)
119 %B = sub uint 123, %A
120 %C = xor uint %B, 4294967295
124 uint %test18(uint %A) { ; C - ~X == X + (1+C)
125 %B = xor uint %A, 4294967295; -~X == 0 - ~X == X+1
126 %C = sub uint 123, %B
130 uint %test19(uint %A, uint %B) {
132 %D = xor uint %C, %A ; A terms cancel, D = B
136 void %test20(uint %A, uint %B) { ; The "swap idiom"
137 %tmp.2 = xor uint %B, %A
138 %tmp.5 = xor uint %tmp.2, %B
139 %tmp.8 = xor uint %tmp.5, %tmp.2
140 store uint %tmp.8, uint* %G1 ; tmp.8 = B
141 store uint %tmp.5, uint* %G2 ; tmp.5 = A
145 int %test21(bool %C, int %A, int %B) {
146 %C2 = xor bool %C, true
147 %D = select bool %C2, int %A, int %B
151 int %test22(bool %X) {
152 %Y = xor bool %X, true
153 %Z = cast bool %Y to int
158 bool %test23(int %a, int %b) {
159 %tmp.2 = xor int %b, %a
160 %tmp.4 = seteq int %tmp.2, %a
164 bool %test24(int %c, int %d) {
165 %tmp.2 = xor int %d, %c
166 %tmp.4 = setne int %tmp.2, %c
170 int %test25(int %g, int %h) {
172 %tmp2 = and int %h2, %g
173 %tmp4 = xor int %tmp2, %g ; (h2&g)^g -> ~h2 & g -> h & g
177 int %test26(int %a, int %b) {
179 %tmp2 = xor int %a, %b2
180 %tmp4 = and int %tmp2, %a ; (a^b2)&a -> ~b2 & a -> b & a
185 int %test27(int %b, int %c, int %d) {
186 %tmp2 = xor int %d, %b
187 %tmp5 = xor int %d, %c
188 %tmp = icmp eq int %tmp2, %tmp5
189 %tmp6 = zext bool %tmp to int
193 int %test28(int %indvar) {
194 %tmp7 = add int %indvar, -2147483647
195 %tmp214 = xor int %tmp7, -2147483648