1 ; RUN: llvm-as -o - %s | llc -march=cellspu > %t1.s
2 ; 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
6 ; RUN: grep {xshw } %t1.s | count 5
7 ; RUN: grep {and } %t1.s | count 5
8 ; RUN: grep {andi } %t1.s | count 2
9 ; RUN: grep {rotmi } %t1.s | count 2
10 ; RUN: grep {rotqmbyi } %t1.s | count 1
11 ; RUN: grep {rotqmbii } %t1.s | count 2
12 ; RUN: grep {rotqmby } %t1.s | count 1
13 ; RUN: grep {rotqmbi } %t1.s | count 1
14 ; RUN: grep {rotqbyi } %t1.s | count 1
15 ; RUN: grep {rotqbii } %t1.s | count 2
16 ; RUN: grep {rotqbybi } %t1.s | count 1
17 ; RUN: grep {sfi } %t1.s | count 3
19 target 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"
22 ; Vector shifts are not currently supported in gcc or llvm assembly. These are
25 ; Shift left i16 via register, note that the second operand to shl is promoted
28 define i16 @shlh_i16_1(i16 %arg1, i16 %arg2) {
29 %A = shl i16 %arg1, %arg2
33 define i16 @shlh_i16_2(i16 %arg1, i16 %arg2) {
34 %A = shl i16 %arg2, %arg1
38 define i16 @shlh_i16_3(i16 signext %arg1, i16 signext %arg2) signext {
39 %A = shl i16 %arg1, %arg2
43 define i16 @shlh_i16_4(i16 signext %arg1, i16 signext %arg2) signext {
44 %A = shl i16 %arg2, %arg1
48 define i16 @shlh_i16_5(i16 zeroext %arg1, i16 zeroext %arg2) zeroext {
49 %A = shl i16 %arg1, %arg2
53 define i16 @shlh_i16_6(i16 zeroext %arg1, i16 zeroext %arg2) zeroext {
54 %A = shl i16 %arg2, %arg1
58 ; Shift left i16 with immediate:
59 define i16 @shlhi_i16_1(i16 %arg1) {
60 %A = shl i16 %arg1, 12
64 ; Should not generate anything other than the return, arg1 << 0 = arg1
65 define i16 @shlhi_i16_2(i16 %arg1) {
70 define i16 @shlhi_i16_3(i16 %arg1) {
71 %A = shl i16 16383, %arg1
75 ; Should generate 0, 0 << arg1 = 0
76 define i16 @shlhi_i16_4(i16 %arg1) {
81 define i16 @shlhi_i16_5(i16 signext %arg1) signext {
82 %A = shl i16 %arg1, 12
86 ; Should not generate anything other than the return, arg1 << 0 = arg1
87 define i16 @shlhi_i16_6(i16 signext %arg1) signext {
92 define i16 @shlhi_i16_7(i16 signext %arg1) signext {
93 %A = shl i16 16383, %arg1
97 ; Should generate 0, 0 << arg1 = 0
98 define i16 @shlhi_i16_8(i16 signext %arg1) signext {
103 define i16 @shlhi_i16_9(i16 zeroext %arg1) zeroext {
104 %A = shl i16 %arg1, 12
108 ; Should not generate anything other than the return, arg1 << 0 = arg1
109 define i16 @shlhi_i16_10(i16 zeroext %arg1) zeroext {
110 %A = shl i16 %arg1, 0
114 define i16 @shlhi_i16_11(i16 zeroext %arg1) zeroext {
115 %A = shl i16 16383, %arg1
119 ; Should generate 0, 0 << arg1 = 0
120 define i16 @shlhi_i16_12(i16 zeroext %arg1) zeroext {
121 %A = shl i16 0, %arg1
125 ; Shift left i32 via register, note that the second operand to shl is promoted
128 define i32 @shl_i32_1(i32 %arg1, i32 %arg2) {
129 %A = shl i32 %arg1, %arg2
133 define i32 @shl_i32_2(i32 %arg1, i32 %arg2) {
134 %A = shl i32 %arg2, %arg1
138 define i32 @shl_i32_3(i32 signext %arg1, i32 signext %arg2) signext {
139 %A = shl i32 %arg1, %arg2
143 define i32 @shl_i32_4(i32 signext %arg1, i32 signext %arg2) signext {
144 %A = shl i32 %arg2, %arg1
148 define i32 @shl_i32_5(i32 zeroext %arg1, i32 zeroext %arg2) zeroext {
149 %A = shl i32 %arg1, %arg2
153 define i32 @shl_i32_6(i32 zeroext %arg1, i32 zeroext %arg2) zeroext {
154 %A = shl i32 %arg2, %arg1
158 ; Shift left i32 with immediate:
159 define i32 @shli_i32_1(i32 %arg1) {
160 %A = shl i32 %arg1, 12
164 ; Should not generate anything other than the return, arg1 << 0 = arg1
165 define i32 @shli_i32_2(i32 %arg1) {
166 %A = shl i32 %arg1, 0
170 define i32 @shli_i32_3(i32 %arg1) {
171 %A = shl i32 16383, %arg1
175 ; Should generate 0, 0 << arg1 = 0
176 define i32 @shli_i32_4(i32 %arg1) {
177 %A = shl i32 0, %arg1
181 define i32 @shli_i32_5(i32 signext %arg1) signext {
182 %A = shl i32 %arg1, 12
186 ; Should not generate anything other than the return, arg1 << 0 = arg1
187 define i32 @shli_i32_6(i32 signext %arg1) signext {
188 %A = shl i32 %arg1, 0
192 define i32 @shli_i32_7(i32 signext %arg1) signext {
193 %A = shl i32 16383, %arg1
197 ; Should generate 0, 0 << arg1 = 0
198 define i32 @shli_i32_8(i32 signext %arg1) signext {
199 %A = shl i32 0, %arg1
203 define i32 @shli_i32_9(i32 zeroext %arg1) zeroext {
204 %A = shl i32 %arg1, 12
208 ; Should not generate anything other than the return, arg1 << 0 = arg1
209 define i32 @shli_i32_10(i32 zeroext %arg1) zeroext {
210 %A = shl i32 %arg1, 0
214 define i32 @shli_i32_11(i32 zeroext %arg1) zeroext {
215 %A = shl i32 16383, %arg1
219 ; Should generate 0, 0 << arg1 = 0
220 define i32 @shli_i32_12(i32 zeroext %arg1) zeroext {
221 %A = shl i32 0, %arg1
227 define i64 @shl_i64_1(i64 %arg1) {
228 %A = shl i64 %arg1, 9
232 define i64 @shl_i64_2(i64 %arg1) {
233 %A = shl i64 %arg1, 3
237 define i64 @shl_i64_3(i64 %arg1, i32 %shift) {
238 %1 = zext i32 %shift to i64
239 %2 = shl i64 %arg1, %1
243 ;; i64 shift right logical (shift 0s from the right)
245 define i64 @lshr_i64_1(i64 %arg1) {
246 %1 = lshr i64 %arg1, 9
250 define i64 @lshr_i64_2(i64 %arg1) {
251 %1 = lshr i64 %arg1, 3
255 define i64 @lshr_i64_3(i64 %arg1, i32 %shift) {
256 %1 = zext i32 %shift to i64
257 %2 = lshr i64 %arg1, %1
261 ;; i64 shift right arithmetic (shift 1s from the right)
263 define i64 @ashr_i64_1(i64 %arg) {
264 %1 = ashr i64 %arg, 9
268 define i64 @ashr_i64_2(i64 %arg) {
269 %1 = ashr i64 %arg, 3
273 define i64 @ashr_i64_3(i64 %arg1, i32 %shift) {
274 %1 = zext i32 %shift to i64
275 %2 = ashr i64 %arg1, %1
279 define i32 @hi32_i64(i64 %arg) {
280 %1 = lshr i64 %arg, 32
281 %2 = trunc i64 %1 to i32