blob: 13d032cacf21e94edf08609bde1045b5617cda35 [file] [log] [blame]
Reid Spencer562b7152007-03-23 21:57:47 +00001; Test that elimination of logical operators works with
2; arbitrary precision integers.
Reid Spencer562b7152007-03-23 21:57:47 +00003; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
Reid Spencer91948d42007-04-14 20:13:02 +00004; RUN: not grep {(and\|xor\|add\|shl\|shr)}
5; END.
Reid Spencer562b7152007-03-23 21:57:47 +00006
7define 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
14define 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
21define 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
28define 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
35define 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}