1; RUN: llc < %s -march=x86 -x86-asm-syntax=intel | \
2; RUN:   grep "ro[rl]" | count 12
3
4define i32 @rotl32(i32 %A, i8 %Amt) {
5	%shift.upgrd.1 = zext i8 %Amt to i32		; <i32> [#uses=1]
6	%B = shl i32 %A, %shift.upgrd.1		; <i32> [#uses=1]
7	%Amt2 = sub i8 32, %Amt		; <i8> [#uses=1]
8	%shift.upgrd.2 = zext i8 %Amt2 to i32		; <i32> [#uses=1]
9	%C = lshr i32 %A, %shift.upgrd.2		; <i32> [#uses=1]
10	%D = or i32 %B, %C		; <i32> [#uses=1]
11	ret i32 %D
12}
13
14define i32 @rotr32(i32 %A, i8 %Amt) {
15	%shift.upgrd.3 = zext i8 %Amt to i32		; <i32> [#uses=1]
16	%B = lshr i32 %A, %shift.upgrd.3		; <i32> [#uses=1]
17	%Amt2 = sub i8 32, %Amt		; <i8> [#uses=1]
18	%shift.upgrd.4 = zext i8 %Amt2 to i32		; <i32> [#uses=1]
19	%C = shl i32 %A, %shift.upgrd.4		; <i32> [#uses=1]
20	%D = or i32 %B, %C		; <i32> [#uses=1]
21	ret i32 %D
22}
23
24define i32 @rotli32(i32 %A) {
25	%B = shl i32 %A, 5		; <i32> [#uses=1]
26	%C = lshr i32 %A, 27		; <i32> [#uses=1]
27	%D = or i32 %B, %C		; <i32> [#uses=1]
28	ret i32 %D
29}
30
31define i32 @rotri32(i32 %A) {
32	%B = lshr i32 %A, 5		; <i32> [#uses=1]
33	%C = shl i32 %A, 27		; <i32> [#uses=1]
34	%D = or i32 %B, %C		; <i32> [#uses=1]
35	ret i32 %D
36}
37
38define i16 @rotl16(i16 %A, i8 %Amt) {
39	%shift.upgrd.5 = zext i8 %Amt to i16		; <i16> [#uses=1]
40	%B = shl i16 %A, %shift.upgrd.5		; <i16> [#uses=1]
41	%Amt2 = sub i8 16, %Amt		; <i8> [#uses=1]
42	%shift.upgrd.6 = zext i8 %Amt2 to i16		; <i16> [#uses=1]
43	%C = lshr i16 %A, %shift.upgrd.6		; <i16> [#uses=1]
44	%D = or i16 %B, %C		; <i16> [#uses=1]
45	ret i16 %D
46}
47
48define i16 @rotr16(i16 %A, i8 %Amt) {
49	%shift.upgrd.7 = zext i8 %Amt to i16		; <i16> [#uses=1]
50	%B = lshr i16 %A, %shift.upgrd.7		; <i16> [#uses=1]
51	%Amt2 = sub i8 16, %Amt		; <i8> [#uses=1]
52	%shift.upgrd.8 = zext i8 %Amt2 to i16		; <i16> [#uses=1]
53	%C = shl i16 %A, %shift.upgrd.8		; <i16> [#uses=1]
54	%D = or i16 %B, %C		; <i16> [#uses=1]
55	ret i16 %D
56}
57
58define i16 @rotli16(i16 %A) {
59	%B = shl i16 %A, 5		; <i16> [#uses=1]
60	%C = lshr i16 %A, 11		; <i16> [#uses=1]
61	%D = or i16 %B, %C		; <i16> [#uses=1]
62	ret i16 %D
63}
64
65define i16 @rotri16(i16 %A) {
66	%B = lshr i16 %A, 5		; <i16> [#uses=1]
67	%C = shl i16 %A, 11		; <i16> [#uses=1]
68	%D = or i16 %B, %C		; <i16> [#uses=1]
69	ret i16 %D
70}
71
72define i8 @rotl8(i8 %A, i8 %Amt) {
73	%B = shl i8 %A, %Amt		; <i8> [#uses=1]
74	%Amt2 = sub i8 8, %Amt		; <i8> [#uses=1]
75	%C = lshr i8 %A, %Amt2		; <i8> [#uses=1]
76	%D = or i8 %B, %C		; <i8> [#uses=1]
77	ret i8 %D
78}
79
80define i8 @rotr8(i8 %A, i8 %Amt) {
81	%B = lshr i8 %A, %Amt		; <i8> [#uses=1]
82	%Amt2 = sub i8 8, %Amt		; <i8> [#uses=1]
83	%C = shl i8 %A, %Amt2		; <i8> [#uses=1]
84	%D = or i8 %B, %C		; <i8> [#uses=1]
85	ret i8 %D
86}
87
88define i8 @rotli8(i8 %A) {
89	%B = shl i8 %A, 5		; <i8> [#uses=1]
90	%C = lshr i8 %A, 3		; <i8> [#uses=1]
91	%D = or i8 %B, %C		; <i8> [#uses=1]
92	ret i8 %D
93}
94
95define i8 @rotri8(i8 %A) {
96	%B = lshr i8 %A, 5		; <i8> [#uses=1]
97	%C = shl i8 %A, 3		; <i8> [#uses=1]
98	%D = or i8 %B, %C		; <i8> [#uses=1]
99	ret i8 %D
100}
101