blob: 5b60dc178fa860e2a09fc117ee65c72632818f08 [file] [log] [blame]
Scott Michel0a92af42007-12-19 20:50:49 +00001; RUN: llvm-as -o - %s | llc -march=cellspu > %t1.s
Scott Michel02d711b2008-12-30 23:28:25 +00002; RUN: grep -w shlh %t1.s | count 9
3; 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 Michel9de5d0d2008-01-11 02:53:15 +000019target 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"
20target triple = "spu"
Scott Michel0a92af42007-12-19 20:50:49 +000021
22; Vector shifts are not currently supported in gcc or llvm assembly. These are
23; not tested.
24
25; Shift left i16 via register, note that the second operand to shl is promoted
26; to a 32-bit type:
27
28define i16 @shlh_i16_1(i16 %arg1, i16 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +000029 %A = shl i16 %arg1, %arg2
30 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000031}
32
33define i16 @shlh_i16_2(i16 %arg1, i16 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +000034 %A = shl i16 %arg2, %arg1
35 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000036}
37
38define i16 @shlh_i16_3(i16 signext %arg1, i16 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +000039 %A = shl i16 %arg1, %arg2
40 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000041}
42
43define i16 @shlh_i16_4(i16 signext %arg1, i16 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +000044 %A = shl i16 %arg2, %arg1
45 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000046}
47
48define i16 @shlh_i16_5(i16 zeroext %arg1, i16 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +000049 %A = shl i16 %arg1, %arg2
50 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000051}
52
53define i16 @shlh_i16_6(i16 zeroext %arg1, i16 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +000054 %A = shl i16 %arg2, %arg1
55 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000056}
57
58; Shift left i16 with immediate:
59define i16 @shlhi_i16_1(i16 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +000060 %A = shl i16 %arg1, 12
61 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000062}
63
64; Should not generate anything other than the return, arg1 << 0 = arg1
65define i16 @shlhi_i16_2(i16 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +000066 %A = shl i16 %arg1, 0
67 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000068}
69
70define i16 @shlhi_i16_3(i16 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +000071 %A = shl i16 16383, %arg1
72 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000073}
74
75; Should generate 0, 0 << arg1 = 0
76define i16 @shlhi_i16_4(i16 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +000077 %A = shl i16 0, %arg1
78 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000079}
80
81define i16 @shlhi_i16_5(i16 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +000082 %A = shl i16 %arg1, 12
83 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000084}
85
86; Should not generate anything other than the return, arg1 << 0 = arg1
87define i16 @shlhi_i16_6(i16 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +000088 %A = shl i16 %arg1, 0
89 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000090}
91
92define i16 @shlhi_i16_7(i16 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +000093 %A = shl i16 16383, %arg1
94 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +000095}
96
97; Should generate 0, 0 << arg1 = 0
98define i16 @shlhi_i16_8(i16 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +000099 %A = shl i16 0, %arg1
100 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000101}
102
103define i16 @shlhi_i16_9(i16 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000104 %A = shl i16 %arg1, 12
105 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000106}
107
108; Should not generate anything other than the return, arg1 << 0 = arg1
109define i16 @shlhi_i16_10(i16 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000110 %A = shl i16 %arg1, 0
111 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000112}
113
114define i16 @shlhi_i16_11(i16 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000115 %A = shl i16 16383, %arg1
116 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000117}
118
119; Should generate 0, 0 << arg1 = 0
120define i16 @shlhi_i16_12(i16 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000121 %A = shl i16 0, %arg1
122 ret i16 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000123}
124
125; Shift left i32 via register, note that the second operand to shl is promoted
126; to a 32-bit type:
127
128define i32 @shl_i32_1(i32 %arg1, i32 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +0000129 %A = shl i32 %arg1, %arg2
130 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000131}
132
133define i32 @shl_i32_2(i32 %arg1, i32 %arg2) {
Scott Michel53dec472008-03-05 23:00:19 +0000134 %A = shl i32 %arg2, %arg1
135 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000136}
137
138define i32 @shl_i32_3(i32 signext %arg1, i32 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000139 %A = shl i32 %arg1, %arg2
140 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000141}
142
143define i32 @shl_i32_4(i32 signext %arg1, i32 signext %arg2) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000144 %A = shl i32 %arg2, %arg1
145 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000146}
147
148define i32 @shl_i32_5(i32 zeroext %arg1, i32 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000149 %A = shl i32 %arg1, %arg2
150 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000151}
152
153define i32 @shl_i32_6(i32 zeroext %arg1, i32 zeroext %arg2) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000154 %A = shl i32 %arg2, %arg1
155 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000156}
157
158; Shift left i32 with immediate:
159define i32 @shli_i32_1(i32 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +0000160 %A = shl i32 %arg1, 12
161 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000162}
163
164; Should not generate anything other than the return, arg1 << 0 = arg1
165define i32 @shli_i32_2(i32 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +0000166 %A = shl i32 %arg1, 0
167 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000168}
169
170define i32 @shli_i32_3(i32 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +0000171 %A = shl i32 16383, %arg1
172 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000173}
174
175; Should generate 0, 0 << arg1 = 0
176define i32 @shli_i32_4(i32 %arg1) {
Scott Michel53dec472008-03-05 23:00:19 +0000177 %A = shl i32 0, %arg1
178 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000179}
180
181define i32 @shli_i32_5(i32 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000182 %A = shl i32 %arg1, 12
183 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000184}
185
186; Should not generate anything other than the return, arg1 << 0 = arg1
187define i32 @shli_i32_6(i32 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000188 %A = shl i32 %arg1, 0
189 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000190}
191
192define i32 @shli_i32_7(i32 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000193 %A = shl i32 16383, %arg1
194 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000195}
196
197; Should generate 0, 0 << arg1 = 0
198define i32 @shli_i32_8(i32 signext %arg1) signext {
Scott Michel53dec472008-03-05 23:00:19 +0000199 %A = shl i32 0, %arg1
200 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000201}
202
203define i32 @shli_i32_9(i32 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000204 %A = shl i32 %arg1, 12
205 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000206}
207
208; Should not generate anything other than the return, arg1 << 0 = arg1
209define i32 @shli_i32_10(i32 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000210 %A = shl i32 %arg1, 0
211 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000212}
213
214define i32 @shli_i32_11(i32 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000215 %A = shl i32 16383, %arg1
216 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000217}
218
219; Should generate 0, 0 << arg1 = 0
220define i32 @shli_i32_12(i32 zeroext %arg1) zeroext {
Scott Michel53dec472008-03-05 23:00:19 +0000221 %A = shl i32 0, %arg1
222 ret i32 %A
Scott Michel0a92af42007-12-19 20:50:49 +0000223}
Scott Michel02d711b2008-12-30 23:28:25 +0000224
225;; i64 shift left
226
227define i64 @shl_i64_1(i64 %arg1) {
228 %A = shl i64 %arg1, 9
229 ret i64 %A
230}
231
232define i64 @shl_i64_2(i64 %arg1) {
233 %A = shl i64 %arg1, 3
234 ret i64 %A
235}
236
237define i64 @shl_i64_3(i64 %arg1, i32 %shift) {
238 %1 = zext i32 %shift to i64
239 %2 = shl i64 %arg1, %1
240 ret i64 %2
241}
242
243;; i64 shift right logical (shift 0s from the right)
244
245define i64 @lshr_i64_1(i64 %arg1) {
246 %1 = lshr i64 %arg1, 9
247 ret i64 %1
248}
249
250define i64 @lshr_i64_2(i64 %arg1) {
251 %1 = lshr i64 %arg1, 3
252 ret i64 %1
253}
254
255define i64 @lshr_i64_3(i64 %arg1, i32 %shift) {
256 %1 = zext i32 %shift to i64
257 %2 = lshr i64 %arg1, %1
258 ret i64 %2
259}
260
261;; i64 shift right arithmetic (shift 1s from the right)
262
263define i64 @ashr_i64_1(i64 %arg) {
264 %1 = ashr i64 %arg, 9
265 ret i64 %1
266}
267
268define i64 @ashr_i64_2(i64 %arg) {
269 %1 = ashr i64 %arg, 3
270 ret i64 %1
271}
272
273define i64 @ashr_i64_3(i64 %arg1, i32 %shift) {
274 %1 = zext i32 %shift to i64
275 %2 = ashr i64 %arg1, %1
276 ret i64 %2
277}