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