blob: 3b6901690080b3d55db006c6110e19623765a10d [file] [log] [blame]
Reid Spencerea8b07e2007-03-23 20:48:34 +00001; This test makes sure that and instructions are properly eliminated.
2; This test is for Integer BitWidth > 64 && BitWidth <= 1024.
3
Reid Spencer91948d42007-04-14 20:13:02 +00004; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep {and }
Reid Spencerea8b07e2007-03-23 20:48:34 +00005
Reid Spencerea8b07e2007-03-23 20:48:34 +00006
7define i999 @test0(i999 %A) {
8 %B = and i999 %A, 0 ; zero result
9 ret i999 %B
10}
11
12define 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
20define 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
28define 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
36define 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
44define i1005 @test2(i1005 %x) {
45 %tmp.2 = and i1005 %x, -1 ; noop
46 ret i1005 %tmp.2
47}
48
49define 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
55define i1 @test4(i737 %x) {
56 %A = and i737 %x, -2147483648
57 %B = icmp ne i737 %A, 0
58 ret i1 %B
59}
60
61define 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
69define 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
77define i1024 @test7(i1024 %A) {
78 %X = ashr i1024 %A, 1016 ;; sign extend
79 %C1 = and i1024 %X, 255
80 ret i1024 %C1
81}