New testcase for rotate instructions. Each function should codegen to a
[oota-llvm.git] / test / CodeGen / X86 / rotate.ll
1 ; RUN: llvm-as < %s | llc -march=x86 -x86-asm-syntax=intel -disable-pattern-isel=0 | grep ro[rl] | wc -l | grep 12
2
3 uint %rotl32(uint %A, ubyte %Amt) {
4         %B = shl uint %A, ubyte %Amt
5         %Amt2 = sub ubyte 32, %Amt
6         %C = shr uint %A, ubyte %Amt2
7         %D = or uint %B, %C
8         ret uint %D
9 }
10
11 uint %rotr32(uint %A, ubyte %Amt) {
12         %B = shr uint %A, ubyte %Amt
13         %Amt2 = sub ubyte 32, %Amt
14         %C = shl uint %A, ubyte %Amt2
15         %D = or uint %B, %C
16         ret uint %D
17 }
18
19 uint %rotli32(uint %A) {
20         %B = shl uint %A, ubyte 5
21         %C = shr uint %A, ubyte 27
22         %D = or uint %B, %C
23         ret uint %D
24 }
25
26 uint %rotri32(uint %A) {
27         %B = shr uint %A, ubyte 5
28         %C = shl uint %A, ubyte 27
29         %D = or uint %B, %C
30         ret uint %D
31 }
32
33 ushort %rotl16(ushort %A, ubyte %Amt) {
34         %B = shl ushort %A, ubyte %Amt
35         %Amt2 = sub ubyte 16, %Amt
36         %C = shr ushort %A, ubyte %Amt2
37         %D = or ushort %B, %C
38         ret ushort %D
39 }
40
41 ushort %rotr16(ushort %A, ubyte %Amt) {
42         %B = shr ushort %A, ubyte %Amt
43         %Amt2 = sub ubyte 16, %Amt
44         %C = shl ushort %A, ubyte %Amt2
45         %D = or ushort %B, %C
46         ret ushort %D
47 }
48
49 ushort %rotli16(ushort %A) {
50         %B = shl ushort %A, ubyte 5
51         %C = shr ushort %A, ubyte 11
52         %D = or ushort %B, %C
53         ret ushort %D
54 }
55
56 ushort %rotri16(ushort %A) {
57         %B = shr ushort %A, ubyte 5
58         %C = shl ushort %A, ubyte 11
59         %D = or ushort %B, %C
60         ret ushort %D
61 }
62
63 ubyte %rotl8(ubyte %A, ubyte %Amt) {
64         %B = shl ubyte %A, ubyte %Amt
65         %Amt2 = sub ubyte 8, %Amt
66         %C = shr ubyte %A, ubyte %Amt2
67         %D = or ubyte %B, %C
68         ret ubyte %D
69 }
70
71 ubyte %rotr8(ubyte %A, ubyte %Amt) {
72         %B = shr ubyte %A, ubyte %Amt
73         %Amt2 = sub ubyte 8, %Amt
74         %C = shl ubyte %A, ubyte %Amt2
75         %D = or ubyte %B, %C
76         ret ubyte %D
77 }
78
79 ubyte %rotli8(ubyte %A) {
80         %B = shl ubyte %A, ubyte 5
81         %C = shr ubyte %A, ubyte 3
82         %D = or ubyte %B, %C
83         ret ubyte %D
84 }
85
86 ubyte %rotri8(ubyte %A) {
87         %B = shr ubyte %A, ubyte 5
88         %C = shl ubyte %A, ubyte 3
89         %D = or ubyte %B, %C
90         ret ubyte %D
91 }