blob: b6629cac2a152a8b9f7bab871c2c42df2599c210 [file] [log] [blame]
Scott Michel0a92af42007-12-19 20:50:49 +00001; RUN: llvm-as -o - %s | llc -march=cellspu > %t1.s
2; RUN: grep shlh %t1.s | count 84
3; RUN: grep shlhi %t1.s | count 51
4; RUN: grep shl %t1.s | count 168
5; RUN: grep shli %t1.s | count 51
6; RUN: grep xshw %t1.s | count 5
7; RUN: grep and %t1.s | count 5
Scott Michel9de5d0d2008-01-11 02:53:15 +00008target datalayout = "E-p:32:32:128-f64:64:128-f32:32:128-i64:32:128-i32:32:128-i16:16:128-i8:8:128-i1:8:128-a0:0:128-v128:128:128-s0:128:128"
9target triple = "spu"
Scott Michel0a92af42007-12-19 20:50:49 +000010
11; Vector shifts are not currently supported in gcc or llvm assembly. These are
12; not tested.
13
14; Shift left i16 via register, note that the second operand to shl is promoted
15; to a 32-bit type:
16
17define i16 @shlh_i16_1(i16 %arg1, i16 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +000018 %A = shl i16 %arg1, %arg2
19 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000020}
21
22define i16 @shlh_i16_2(i16 %arg1, i16 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +000023 %A = shl i16 %arg2, %arg1
24 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000025}
26
27define i16 @shlh_i16_3(i16 signext %arg1, i16 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +000028 %A = shl i16 %arg1, %arg2
29 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000030}
31
32define i16 @shlh_i16_4(i16 signext %arg1, i16 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +000033 %A = shl i16 %arg2, %arg1
34 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000035}
36
37define i16 @shlh_i16_5(i16 zeroext %arg1, i16 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +000038 %A = shl i16 %arg1, %arg2
39 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000040}
41
42define i16 @shlh_i16_6(i16 zeroext %arg1, i16 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +000043 %A = shl i16 %arg2, %arg1
44 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000045}
46
47; Shift left i16 with immediate:
48define i16 @shlhi_i16_1(i16 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +000049 %A = shl i16 %arg1, 12
50 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000051}
52
53; Should not generate anything other than the return, arg1 << 0 = arg1
54define i16 @shlhi_i16_2(i16 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +000055 %A = shl i16 %arg1, 0
56 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000057}
58
59define i16 @shlhi_i16_3(i16 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +000060 %A = shl i16 16383, %arg1
61 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000062}
63
64; Should generate 0, 0 << arg1 = 0
65define i16 @shlhi_i16_4(i16 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +000066 %A = shl i16 0, %arg1
67 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000068}
69
70define i16 @shlhi_i16_5(i16 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +000071 %A = shl i16 %arg1, 12
72 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000073}
74
75; Should not generate anything other than the return, arg1 << 0 = arg1
76define i16 @shlhi_i16_6(i16 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +000077 %A = shl i16 %arg1, 0
78 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000079}
80
81define i16 @shlhi_i16_7(i16 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +000082 %A = shl i16 16383, %arg1
83 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000084}
85
86; Should generate 0, 0 << arg1 = 0
87define i16 @shlhi_i16_8(i16 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +000088 %A = shl i16 0, %arg1
89 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000090}
91
92define i16 @shlhi_i16_9(i16 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +000093 %A = shl i16 %arg1, 12
94 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000095}
96
97; Should not generate anything other than the return, arg1 << 0 = arg1
98define i16 @shlhi_i16_10(i16 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +000099 %A = shl i16 %arg1, 0
100 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000101}
102
103define i16 @shlhi_i16_11(i16 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000104 %A = shl i16 16383, %arg1
105 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000106}
107
108; Should generate 0, 0 << arg1 = 0
109define i16 @shlhi_i16_12(i16 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000110 %A = shl i16 0, %arg1
111 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000112}
113
114; Shift left i32 via register, note that the second operand to shl is promoted
115; to a 32-bit type:
116
117define i32 @shl_i32_1(i32 %arg1, i32 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +0000118 %A = shl i32 %arg1, %arg2
119 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000120}
121
122define i32 @shl_i32_2(i32 %arg1, i32 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +0000123 %A = shl i32 %arg2, %arg1
124 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000125}
126
127define i32 @shl_i32_3(i32 signext %arg1, i32 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000128 %A = shl i32 %arg1, %arg2
129 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000130}
131
132define i32 @shl_i32_4(i32 signext %arg1, i32 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000133 %A = shl i32 %arg2, %arg1
134 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000135}
136
137define i32 @shl_i32_5(i32 zeroext %arg1, i32 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000138 %A = shl i32 %arg1, %arg2
139 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000140}
141
142define i32 @shl_i32_6(i32 zeroext %arg1, i32 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000143 %A = shl i32 %arg2, %arg1
144 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000145}
146
147; Shift left i32 with immediate:
148define i32 @shli_i32_1(i32 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +0000149 %A = shl i32 %arg1, 12
150 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000151}
152
153; Should not generate anything other than the return, arg1 << 0 = arg1
154define i32 @shli_i32_2(i32 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +0000155 %A = shl i32 %arg1, 0
156 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000157}
158
159define i32 @shli_i32_3(i32 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +0000160 %A = shl i32 16383, %arg1
161 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000162}
163
164; Should generate 0, 0 << arg1 = 0
165define i32 @shli_i32_4(i32 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +0000166 %A = shl i32 0, %arg1
167 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000168}
169
170define i32 @shli_i32_5(i32 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000171 %A = shl i32 %arg1, 12
172 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000173}
174
175; Should not generate anything other than the return, arg1 << 0 = arg1
176define i32 @shli_i32_6(i32 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000177 %A = shl i32 %arg1, 0
178 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000179}
180
181define i32 @shli_i32_7(i32 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000182 %A = shl i32 16383, %arg1
183 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000184}
185
186; Should generate 0, 0 << arg1 = 0
187define i32 @shli_i32_8(i32 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000188 %A = shl i32 0, %arg1
189 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000190}
191
192define i32 @shli_i32_9(i32 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000193 %A = shl i32 %arg1, 12
194 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000195}
196
197; Should not generate anything other than the return, arg1 << 0 = arg1
198define i32 @shli_i32_10(i32 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000199 %A = shl i32 %arg1, 0
200 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000201}
202
203define i32 @shli_i32_11(i32 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000204 %A = shl i32 16383, %arg1
205 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000206}
207
208; Should generate 0, 0 << arg1 = 0
209define i32 @shli_i32_12(i32 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000210 %A = shl i32 0, %arg1
211 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000212}