merge some tests.
[oota-llvm.git] / test / Transforms / InstCombine / apint-elim-logicalops.ll
1 ; Test that elimination of logical operators works with 
2 ; arbitrary precision integers.
3 ; RUN: opt < %s -instcombine -S | \
4 ; RUN:    not grep {(and\|xor\|add\|shl\|shr)}
5 ; END.
6
7 define i33 @test1(i33 %x) {
8         %tmp.1 = and i33 %x, 65535           ; <i33> [#uses=1]
9         %tmp.2 = xor i33 %tmp.1, -32768      ; <i33> [#uses=1]
10         %tmp.3 = add i33 %tmp.2, 32768       ; <i33> [#uses=1]
11         ret i33 %tmp.3
12 }
13
14 define i33 @test2(i33 %x) {
15         %tmp.1 = and i33 %x, 65535           ; <i33> [#uses=1]
16         %tmp.2 = xor i33 %tmp.1, 32768       ; <i33> [#uses=1]
17         %tmp.3 = add i33 %tmp.2, -32768      ; <i33> [#uses=1]
18         ret i33 %tmp.3
19 }
20
21 define i33 @test3(i16 %P) {
22         %tmp.1 = zext i16 %P to i33          ; <i33> [#uses=1]
23         %tmp.4 = xor i33 %tmp.1, 32768       ; <i33> [#uses=1]
24         %tmp.5 = add i33 %tmp.4, -32768      ; <i33> [#uses=1]
25         ret i33 %tmp.5
26 }
27
28 define i33 @test5(i33 %x) {
29         %tmp.1 = and i33 %x, 254
30         %tmp.2 = xor i33 %tmp.1, 128
31         %tmp.3 = add i33 %tmp.2, -128
32         ret i33 %tmp.3
33 }
34
35 define i33 @test6(i33 %x) {
36         %tmp.2 = shl i33 %x, 16           ; <i33> [#uses=1]
37         %tmp.4 = lshr i33 %tmp.2, 16      ; <i33> [#uses=1]
38         ret i33 %tmp.4
39 }