blob: 84ac4fa79f51feaaf507f0ae54006c0e69255820 [file] [log] [blame]
Scott Michel0a92af42007-12-19 20:50:49 +00001; RUN: llvm-as -o - %s | llc -march=cellspu > %t1.s
Scott Michel477dc852008-12-31 00:08:25 +00002; RUN: grep -w shlh %t1.s | count 9
Scott Michel02d711b2008-12-30 23:28:25 +00003; RUN: grep -w shlhi %t1.s | count 3
4; RUN: grep -w shl %t1.s | count 9
5; RUN: grep -w shli %t1.s | count 3
6; RUN: grep -w xshw %t1.s | count 5
7; RUN: grep -w and %t1.s | count 5
8; RUN: grep -w andi %t1.s | count 2
9; RUN: grep -w rotmi %t1.s | count 2
10; RUN: grep -w rotqmbyi %t1.s | count 1
11; RUN: grep -w rotqmbii %t1.s | count 2
12; RUN: grep -w rotqmby %t1.s | count 1
13; RUN: grep -w rotqmbi %t1.s | count 1
14; RUN: grep -w rotqbyi %t1.s | count 1
15; RUN: grep -w rotqbii %t1.s | count 2
16; RUN: grep -w rotqbybi %t1.s | count 1
17; RUN: grep -w sfi %t1.s | count 3
18
Scott Michel477dc852008-12-31 00:08:25 +000019; XFAIL: *
20
Scott Michel9de5d0d2008-01-11 02:53:15 +000021target 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"
22target triple = "spu"
Scott Michel0a92af42007-12-19 20:50:49 +000023
24; Vector shifts are not currently supported in gcc or llvm assembly. These are
25; not tested.
26
27; Shift left i16 via register, note that the second operand to shl is promoted
28; to a 32-bit type:
29
30define i16 @shlh_i16_1(i16 %arg1, i16 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +000031 %A = shl i16 %arg1, %arg2
32 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000033}
34
35define i16 @shlh_i16_2(i16 %arg1, i16 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +000036 %A = shl i16 %arg2, %arg1
37 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000038}
39
40define i16 @shlh_i16_3(i16 signext %arg1, i16 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +000041 %A = shl i16 %arg1, %arg2
42 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000043}
44
45define i16 @shlh_i16_4(i16 signext %arg1, i16 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +000046 %A = shl i16 %arg2, %arg1
47 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000048}
49
50define i16 @shlh_i16_5(i16 zeroext %arg1, i16 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +000051 %A = shl i16 %arg1, %arg2
52 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000053}
54
55define i16 @shlh_i16_6(i16 zeroext %arg1, i16 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +000056 %A = shl i16 %arg2, %arg1
57 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000058}
59
60; Shift left i16 with immediate:
61define i16 @shlhi_i16_1(i16 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +000062 %A = shl i16 %arg1, 12
63 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000064}
65
66; Should not generate anything other than the return, arg1 << 0 = arg1
67define i16 @shlhi_i16_2(i16 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +000068 %A = shl i16 %arg1, 0
69 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000070}
71
72define i16 @shlhi_i16_3(i16 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +000073 %A = shl i16 16383, %arg1
74 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000075}
76
77; Should generate 0, 0 << arg1 = 0
78define i16 @shlhi_i16_4(i16 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +000079 %A = shl i16 0, %arg1
80 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000081}
82
83define i16 @shlhi_i16_5(i16 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +000084 %A = shl i16 %arg1, 12
85 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000086}
87
88; Should not generate anything other than the return, arg1 << 0 = arg1
89define i16 @shlhi_i16_6(i16 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +000090 %A = shl i16 %arg1, 0
91 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000092}
93
94define i16 @shlhi_i16_7(i16 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +000095 %A = shl i16 16383, %arg1
96 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000097}
98
99; Should generate 0, 0 << arg1 = 0
100define i16 @shlhi_i16_8(i16 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000101 %A = shl i16 0, %arg1
102 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000103}
104
105define i16 @shlhi_i16_9(i16 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000106 %A = shl i16 %arg1, 12
107 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000108}
109
110; Should not generate anything other than the return, arg1 << 0 = arg1
111define i16 @shlhi_i16_10(i16 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000112 %A = shl i16 %arg1, 0
113 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000114}
115
116define i16 @shlhi_i16_11(i16 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000117 %A = shl i16 16383, %arg1
118 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000119}
120
121; Should generate 0, 0 << arg1 = 0
122define i16 @shlhi_i16_12(i16 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000123 %A = shl i16 0, %arg1
124 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000125}
126
127; Shift left i32 via register, note that the second operand to shl is promoted
128; to a 32-bit type:
129
130define i32 @shl_i32_1(i32 %arg1, i32 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +0000131 %A = shl i32 %arg1, %arg2
132 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000133}
134
135define i32 @shl_i32_2(i32 %arg1, i32 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +0000136 %A = shl i32 %arg2, %arg1
137 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000138}
139
140define i32 @shl_i32_3(i32 signext %arg1, i32 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000141 %A = shl i32 %arg1, %arg2
142 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000143}
144
145define i32 @shl_i32_4(i32 signext %arg1, i32 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000146 %A = shl i32 %arg2, %arg1
147 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000148}
149
150define i32 @shl_i32_5(i32 zeroext %arg1, i32 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000151 %A = shl i32 %arg1, %arg2
152 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000153}
154
155define i32 @shl_i32_6(i32 zeroext %arg1, i32 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000156 %A = shl i32 %arg2, %arg1
157 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000158}
159
160; Shift left i32 with immediate:
161define i32 @shli_i32_1(i32 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +0000162 %A = shl i32 %arg1, 12
163 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000164}
165
166; Should not generate anything other than the return, arg1 << 0 = arg1
167define i32 @shli_i32_2(i32 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +0000168 %A = shl i32 %arg1, 0
169 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000170}
171
172define i32 @shli_i32_3(i32 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +0000173 %A = shl i32 16383, %arg1
174 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000175}
176
177; Should generate 0, 0 << arg1 = 0
178define i32 @shli_i32_4(i32 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +0000179 %A = shl i32 0, %arg1
180 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000181}
182
183define i32 @shli_i32_5(i32 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000184 %A = shl i32 %arg1, 12
185 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000186}
187
188; Should not generate anything other than the return, arg1 << 0 = arg1
189define i32 @shli_i32_6(i32 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000190 %A = shl i32 %arg1, 0
191 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000192}
193
194define i32 @shli_i32_7(i32 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000195 %A = shl i32 16383, %arg1
196 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000197}
198
199; Should generate 0, 0 << arg1 = 0
200define i32 @shli_i32_8(i32 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000201 %A = shl i32 0, %arg1
202 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000203}
204
205define i32 @shli_i32_9(i32 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000206 %A = shl i32 %arg1, 12
207 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000208}
209
210; Should not generate anything other than the return, arg1 << 0 = arg1
211define i32 @shli_i32_10(i32 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000212 %A = shl i32 %arg1, 0
213 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000214}
215
216define i32 @shli_i32_11(i32 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000217 %A = shl i32 16383, %arg1
218 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000219}
220
221; Should generate 0, 0 << arg1 = 0
222define i32 @shli_i32_12(i32 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000223 %A = shl i32 0, %arg1
224 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000225}
Scott Michel02d711b2008-12-30 23:28:25 +0000226
227;; i64 shift left
228
229define i64 @shl_i64_1(i64 %arg1) {
230 %A = shl i64 %arg1, 9
231 ret i64 %A
232}
233
234define i64 @shl_i64_2(i64 %arg1) {
235 %A = shl i64 %arg1, 3
236 ret i64 %A
237}
238
239define i64 @shl_i64_3(i64 %arg1, i32 %shift) {
240 %1 = zext i32 %shift to i64
241 %2 = shl i64 %arg1, %1
242 ret i64 %2
243}
244
245;; i64 shift right logical (shift 0s from the right)
246
247define i64 @lshr_i64_1(i64 %arg1) {
248 %1 = lshr i64 %arg1, 9
249 ret i64 %1
250}
251
252define i64 @lshr_i64_2(i64 %arg1) {
253 %1 = lshr i64 %arg1, 3
254 ret i64 %1
255}
256
257define i64 @lshr_i64_3(i64 %arg1, i32 %shift) {
258 %1 = zext i32 %shift to i64
259 %2 = lshr i64 %arg1, %1
260 ret i64 %2
261}
262
263;; i64 shift right arithmetic (shift 1s from the right)
264
265define i64 @ashr_i64_1(i64 %arg) {
266 %1 = ashr i64 %arg, 9
267 ret i64 %1
268}
269
270define i64 @ashr_i64_2(i64 %arg) {
271 %1 = ashr i64 %arg, 3
272 ret i64 %1
273}
274
275define i64 @ashr_i64_3(i64 %arg1, i32 %shift) {
276 %1 = zext i32 %shift to i64
277 %2 = ashr i64 %arg1, %1
278 ret i64 %2
279}