For PR1319:
[oota-llvm.git] / test / Transforms / InstCombine / apint-and2.ll
1 ; This test makes sure that and instructions are properly eliminated.
2 ; This test is for Integer BitWidth > 64 && BitWidth <= 1024.
3
4 ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep {and }
5
6
7 define i999 @test0(i999 %A) {
8         %B = and i999 %A, 0 ; zero result
9         ret i999 %B
10 }
11
12 define i477 @test1(i477 %A, i477 %B) {
13         ;; (~A & ~B) == (~(A | B)) - De Morgan's Law
14         %NotA = xor i477 %A, -1
15         %NotB = xor i477 %B, -1
16         %C1 = and i477 %NotA, %NotB
17         ret i477 %C1
18 }
19
20 define i129 @tst(i129 %A, i129 %B) {
21         ;; (~A & ~B) == (~(A | B)) - De Morgan's Law
22         %NotA = xor i129 %A, -1
23         %NotB = xor i129 %B, -1
24         %C1 = and i129 %NotA, %NotB
25         ret i129 %C1
26 }
27
28 define i65 @test(i65 %A, i65 %B) {
29         ;; (~A & ~B) == (~(A | B)) - De Morgan's Law
30         %NotA = xor i65 %A, -1
31         %NotB = xor i65 -1, %B
32         %C1 = and i65 %NotA, %NotB
33         ret i65 %C1
34 }
35
36 define i66 @tes(i66 %A, i66 %B) {
37         ;; (~A & ~B) == (~(A | B)) - De Morgan's Law
38         %NotA = xor i66 %A, -1
39         %NotB = xor i66 %B, -1
40         %C1 = and i66 %NotA, %NotB
41         ret i66 %C1
42 }
43
44 define i1005 @test2(i1005 %x) {
45         %tmp.2 = and i1005 %x, -1 ; noop
46         ret i1005 %tmp.2
47 }
48
49 define i123 @test3(i123 %x) {
50         %tmp.0 = and i123 %x, 127
51         %tmp.2 = and i123 %tmp.0, 128
52         ret i123 %tmp.2
53 }
54
55 define i1 @test4(i737 %x) {
56         %A = and i737 %x, -2147483648
57         %B = icmp ne i737 %A, 0
58         ret i1 %B
59 }
60
61 define i117 @test5(i117 %A, i117* %P) {
62         %B = or i117 %A, 3
63         %C = xor i117 %B, 12
64         store i117 %C, i117* %P
65         %r = and i117 %C, 3
66         ret i117 %r
67 }
68
69 define i117 @test6(i117 %A, i117 %B) {
70         ;; ~(~X & Y) --> (X | ~Y)
71         %t0 = xor i117 %A, -1
72         %t1 = and i117 %t0, %B
73         %r = xor i117 %t1, -1
74         ret i117 %r
75 }
76
77 define i1024 @test7(i1024 %A) {
78         %X = ashr i1024 %A, 1016 ;; sign extend
79         %C1 = and i1024 %X, 255
80         ret i1024 %C1
81 }