blob: d754260cf0e230c8c788c18419b91e531a087b55 [file] [log] [blame]
Reid Spencer2341c222007-02-02 02:16:23 +00001; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \
Reid Spencer91948d42007-04-14 20:13:02 +00002; RUN: not grep {(and\|xor\|add\|shl\|shr)}
Chris Lattner04d4a722005-09-24 23:42:18 +00003
4int %test1(int %x) {
5 %tmp.1 = and int %x, 65535 ; <int> [#uses=1]
6 %tmp.2 = xor int %tmp.1, -32768 ; <int> [#uses=1]
7 %tmp.3 = add int %tmp.2, 32768 ; <int> [#uses=1]
8 ret int %tmp.3
9}
10
11int %test2(int %x) {
12 %tmp.1 = and int %x, 65535 ; <int> [#uses=1]
13 %tmp.2 = xor int %tmp.1, 32768 ; <int> [#uses=1]
14 %tmp.3 = add int %tmp.2, -32768 ; <int> [#uses=1]
15 ret int %tmp.3
16}
17
18int %test3(ushort %P) {
19 %tmp.1 = cast ushort %P to int ; <int> [#uses=1]
20 %tmp.4 = xor int %tmp.1, 32768 ; <int> [#uses=1]
21 %tmp.5 = add int %tmp.4, -32768 ; <int> [#uses=1]
22 ret int %tmp.5
23}
24
25uint %test4(ushort %P) {
26 %tmp.1 = cast ushort %P to uint ; <uint> [#uses=1]
27 %tmp.4 = xor uint %tmp.1, 32768 ; <uint> [#uses=1]
28 %tmp.5 = add uint %tmp.4, 4294934528 ; <uint> [#uses=1]
29 ret uint %tmp.5
30}
31
32int %test5(int %x) {
33 %tmp.1 = and int %x, 254
34 %tmp.2 = xor int %tmp.1, 128
35 %tmp.3 = add int %tmp.2, -128
36 ret int %tmp.3
37}
38
39int %test6(int %x) {
40 %tmp.2 = shl int %x, ubyte 16 ; <int> [#uses=1]
41 %tmp.4 = shr int %tmp.2, ubyte 16 ; <int> [#uses=1]
42 ret int %tmp.4
43}