Split the or and xor tests into two separate files
[oota-llvm.git] / test / Transforms / InstCombine / xor.ll
1 ; This test makes sure that these instructions are properly eliminated.
2 ;
3
4 ; RUN: as < %s | opt -instcombine | dis | not grep 'xor '
5
6 implementation
7
8 bool %test5(bool %A) {
9         %B = xor bool %A, false
10         ret bool %B
11 }
12
13 int %test6(int %A) {
14         %B = xor int %A, 0
15         ret int %B
16 }
17
18 bool %test7(bool %A) {
19         %B = xor bool %A, %A
20         ret bool %B
21 }
22
23 int %test8(int %A) {
24         %B = xor int %A, %A
25         ret int %B
26 }
27
28 int %test11(int %A) {    ; A ^ ~A == -1
29         %NotA = xor int -1, %A
30         %B = xor int %A, %NotA
31         ret int %B
32 }
33
34 uint %test13(uint %A) { ; (A|B)^B == A & (~B)
35         %t1 = or uint %A, 123
36         %r  = xor uint %t1, 123
37         ret uint %r
38 }
39
40 ubyte %test15(ubyte %A) {
41         %B = xor ubyte %A, 17
42         %C = xor ubyte %B, 17
43         ret ubyte %C
44 }
45
46 int %test16(int %A, int %B) {     ; (A & C1)^(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0
47         %A1 = and int %A, 7
48         %B1 = and int %B, 128
49         %OROK = xor int %A1, %B1
50         ret int %OROK
51 }
52
53 ubyte %test18(bool %c) {
54         %d = xor bool %c, true    ; invert the condition
55         br bool %d, label %True, label %False
56 True:
57         ret ubyte 1
58 False:
59         ret ubyte 3
60 }
61
62 bool %test19(ubyte %A) {
63         %B = xor ubyte %A, 123      ; xor can be eliminated
64         %C = seteq ubyte %B, 34
65         ret bool %C
66 }