blob: 3b7dacd3cd762e3bef2aef22074d333c502b0918 [file] [log] [blame]
Scott Michel0a92af42007-12-19 20:50:49 +00001; RUN: llvm-as -o - %s | llc -march=cellspu > %t1.s
Duncan Sands74789ea2009-01-21 09:41:42 +00002; RUN: grep {shlh } %t1.s | count 9
3; RUN: grep {shlhi } %t1.s | count 3
4; RUN: grep {shl } %t1.s | count 9
5; RUN: grep {shli } %t1.s | count 3
Duncan Sands74789ea2009-01-21 09:41:42 +00006; RUN: grep {andi } %t1.s | count 2
7; RUN: grep {rotmi } %t1.s | count 2
8; RUN: grep {rotqmbyi } %t1.s | count 1
9; RUN: grep {rotqmbii } %t1.s | count 2
10; RUN: grep {rotqmby } %t1.s | count 1
11; RUN: grep {rotqmbi } %t1.s | count 1
12; RUN: grep {rotqbyi } %t1.s | count 1
13; RUN: grep {rotqbii } %t1.s | count 2
14; RUN: grep {rotqbybi } %t1.s | count 1
15; RUN: grep {sfi } %t1.s | count 3
Scott Michel02d711b2008-12-30 23:28:25 +000016
Scott Michel9de5d0d2008-01-11 02:53:15 +000017target 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"
18target triple = "spu"
Scott Michel0a92af42007-12-19 20:50:49 +000019
20; Vector shifts are not currently supported in gcc or llvm assembly. These are
21; not tested.
22
23; Shift left i16 via register, note that the second operand to shl is promoted
24; to a 32-bit type:
25
26define i16 @shlh_i16_1(i16 %arg1, i16 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +000027 %A = shl i16 %arg1, %arg2
28 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000029}
30
31define i16 @shlh_i16_2(i16 %arg1, i16 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +000032 %A = shl i16 %arg2, %arg1
33 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000034}
35
36define i16 @shlh_i16_3(i16 signext %arg1, i16 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +000037 %A = shl i16 %arg1, %arg2
38 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000039}
40
41define i16 @shlh_i16_4(i16 signext %arg1, i16 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +000042 %A = shl i16 %arg2, %arg1
43 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000044}
45
46define i16 @shlh_i16_5(i16 zeroext %arg1, i16 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +000047 %A = shl i16 %arg1, %arg2
48 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000049}
50
51define i16 @shlh_i16_6(i16 zeroext %arg1, i16 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +000052 %A = shl i16 %arg2, %arg1
53 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000054}
55
56; Shift left i16 with immediate:
57define i16 @shlhi_i16_1(i16 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +000058 %A = shl i16 %arg1, 12
59 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000060}
61
62; Should not generate anything other than the return, arg1 << 0 = arg1
63define i16 @shlhi_i16_2(i16 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +000064 %A = shl i16 %arg1, 0
65 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000066}
67
68define i16 @shlhi_i16_3(i16 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +000069 %A = shl i16 16383, %arg1
70 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000071}
72
73; Should generate 0, 0 << arg1 = 0
74define i16 @shlhi_i16_4(i16 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +000075 %A = shl i16 0, %arg1
76 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000077}
78
79define i16 @shlhi_i16_5(i16 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +000080 %A = shl i16 %arg1, 12
81 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000082}
83
84; Should not generate anything other than the return, arg1 << 0 = arg1
85define i16 @shlhi_i16_6(i16 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +000086 %A = shl i16 %arg1, 0
87 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000088}
89
90define i16 @shlhi_i16_7(i16 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +000091 %A = shl i16 16383, %arg1
92 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000093}
94
95; Should generate 0, 0 << arg1 = 0
96define i16 @shlhi_i16_8(i16 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +000097 %A = shl i16 0, %arg1
98 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000099}
100
101define i16 @shlhi_i16_9(i16 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000102 %A = shl i16 %arg1, 12
103 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000104}
105
106; Should not generate anything other than the return, arg1 << 0 = arg1
107define i16 @shlhi_i16_10(i16 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000108 %A = shl i16 %arg1, 0
109 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000110}
111
112define i16 @shlhi_i16_11(i16 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000113 %A = shl i16 16383, %arg1
114 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000115}
116
117; Should generate 0, 0 << arg1 = 0
118define i16 @shlhi_i16_12(i16 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000119 %A = shl i16 0, %arg1
120 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000121}
122
123; Shift left i32 via register, note that the second operand to shl is promoted
124; to a 32-bit type:
125
126define i32 @shl_i32_1(i32 %arg1, i32 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +0000127 %A = shl i32 %arg1, %arg2
128 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000129}
130
131define i32 @shl_i32_2(i32 %arg1, i32 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +0000132 %A = shl i32 %arg2, %arg1
133 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000134}
135
136define i32 @shl_i32_3(i32 signext %arg1, i32 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000137 %A = shl i32 %arg1, %arg2
138 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000139}
140
141define i32 @shl_i32_4(i32 signext %arg1, i32 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000142 %A = shl i32 %arg2, %arg1
143 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000144}
145
146define i32 @shl_i32_5(i32 zeroext %arg1, i32 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000147 %A = shl i32 %arg1, %arg2
148 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000149}
150
151define i32 @shl_i32_6(i32 zeroext %arg1, i32 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000152 %A = shl i32 %arg2, %arg1
153 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000154}
155
156; Shift left i32 with immediate:
157define i32 @shli_i32_1(i32 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +0000158 %A = shl i32 %arg1, 12
159 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000160}
161
162; Should not generate anything other than the return, arg1 << 0 = arg1
163define i32 @shli_i32_2(i32 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +0000164 %A = shl i32 %arg1, 0
165 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000166}
167
168define i32 @shli_i32_3(i32 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +0000169 %A = shl i32 16383, %arg1
170 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000171}
172
173; Should generate 0, 0 << arg1 = 0
174define i32 @shli_i32_4(i32 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +0000175 %A = shl i32 0, %arg1
176 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000177}
178
179define i32 @shli_i32_5(i32 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000180 %A = shl i32 %arg1, 12
181 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000182}
183
184; Should not generate anything other than the return, arg1 << 0 = arg1
185define i32 @shli_i32_6(i32 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000186 %A = shl i32 %arg1, 0
187 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000188}
189
190define i32 @shli_i32_7(i32 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000191 %A = shl i32 16383, %arg1
192 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000193}
194
195; Should generate 0, 0 << arg1 = 0
196define i32 @shli_i32_8(i32 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000197 %A = shl i32 0, %arg1
198 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000199}
200
201define i32 @shli_i32_9(i32 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000202 %A = shl i32 %arg1, 12
203 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000204}
205
206; Should not generate anything other than the return, arg1 << 0 = arg1
207define i32 @shli_i32_10(i32 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000208 %A = shl i32 %arg1, 0
209 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000210}
211
212define i32 @shli_i32_11(i32 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000213 %A = shl i32 16383, %arg1
214 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000215}
216
217; Should generate 0, 0 << arg1 = 0
218define i32 @shli_i32_12(i32 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000219 %A = shl i32 0, %arg1
220 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000221}
Scott Michel02d711b2008-12-30 23:28:25 +0000222
223;; i64 shift left
224
225define i64 @shl_i64_1(i64 %arg1) {
226 %A = shl i64 %arg1, 9
227 ret i64 %A
228}
229
230define i64 @shl_i64_2(i64 %arg1) {
231 %A = shl i64 %arg1, 3
232 ret i64 %A
233}
234
235define i64 @shl_i64_3(i64 %arg1, i32 %shift) {
236 %1 = zext i32 %shift to i64
237 %2 = shl i64 %arg1, %1
238 ret i64 %2
239}
240
241;; i64 shift right logical (shift 0s from the right)
242
243define i64 @lshr_i64_1(i64 %arg1) {
244 %1 = lshr i64 %arg1, 9
245 ret i64 %1
246}
247
248define i64 @lshr_i64_2(i64 %arg1) {
249 %1 = lshr i64 %arg1, 3
250 ret i64 %1
251}
252
253define i64 @lshr_i64_3(i64 %arg1, i32 %shift) {
254 %1 = zext i32 %shift to i64
255 %2 = lshr i64 %arg1, %1
256 ret i64 %2
257}
258
259;; i64 shift right arithmetic (shift 1s from the right)
260
261define i64 @ashr_i64_1(i64 %arg) {
262 %1 = ashr i64 %arg, 9
263 ret i64 %1
264}
265
266define i64 @ashr_i64_2(i64 %arg) {
267 %1 = ashr i64 %arg, 3
268 ret i64 %1
269}
270
271define i64 @ashr_i64_3(i64 %arg1, i32 %shift) {
272 %1 = zext i32 %shift to i64
273 %2 = ashr i64 %arg1, %1
274 ret i64 %2
275}
Scott Michelc9c8b2a2009-01-26 03:31:40 +0000276
277define i32 @hi32_i64(i64 %arg) {
278 %1 = lshr i64 %arg, 32
279 %2 = trunc i64 %1 to i32
280 ret i32 %2
281}