1 ; RUN: llc < %s -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 2
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 4
18 ; RUN: cat %t1.s | FileCheck %s
20 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"
23 ; Vector shifts are not currently supported in gcc or llvm assembly. These are
26 ; Shift left i16 via register, note that the second operand to shl is promoted
29 define i16 @shlh_i16_1(i16 %arg1, i16 %arg2) {
30 %A = shl i16 %arg1, %arg2
34 define i16 @shlh_i16_2(i16 %arg1, i16 %arg2) {
35 %A = shl i16 %arg2, %arg1
39 define i16 @shlh_i16_3(i16 signext %arg1, i16 signext %arg2) signext {
40 %A = shl i16 %arg1, %arg2
44 define i16 @shlh_i16_4(i16 signext %arg1, i16 signext %arg2) signext {
45 %A = shl i16 %arg2, %arg1
49 define i16 @shlh_i16_5(i16 zeroext %arg1, i16 zeroext %arg2) zeroext {
50 %A = shl i16 %arg1, %arg2
54 define i16 @shlh_i16_6(i16 zeroext %arg1, i16 zeroext %arg2) zeroext {
55 %A = shl i16 %arg2, %arg1
59 ; Shift left i16 with immediate:
60 define i16 @shlhi_i16_1(i16 %arg1) {
61 %A = shl i16 %arg1, 12
65 ; Should not generate anything other than the return, arg1 << 0 = arg1
66 define i16 @shlhi_i16_2(i16 %arg1) {
71 define i16 @shlhi_i16_3(i16 %arg1) {
72 %A = shl i16 16383, %arg1
76 ; Should generate 0, 0 << arg1 = 0
77 define i16 @shlhi_i16_4(i16 %arg1) {
82 define i16 @shlhi_i16_5(i16 signext %arg1) signext {
83 %A = shl i16 %arg1, 12
87 ; Should not generate anything other than the return, arg1 << 0 = arg1
88 define i16 @shlhi_i16_6(i16 signext %arg1) signext {
93 define i16 @shlhi_i16_7(i16 signext %arg1) signext {
94 %A = shl i16 16383, %arg1
98 ; Should generate 0, 0 << arg1 = 0
99 define i16 @shlhi_i16_8(i16 signext %arg1) signext {
100 %A = shl i16 0, %arg1
104 define i16 @shlhi_i16_9(i16 zeroext %arg1) zeroext {
105 %A = shl i16 %arg1, 12
109 ; Should not generate anything other than the return, arg1 << 0 = arg1
110 define i16 @shlhi_i16_10(i16 zeroext %arg1) zeroext {
111 %A = shl i16 %arg1, 0
115 define i16 @shlhi_i16_11(i16 zeroext %arg1) zeroext {
116 %A = shl i16 16383, %arg1
120 ; Should generate 0, 0 << arg1 = 0
121 define i16 @shlhi_i16_12(i16 zeroext %arg1) zeroext {
122 %A = shl i16 0, %arg1
126 ; Shift left i32 via register, note that the second operand to shl is promoted
129 define i32 @shl_i32_1(i32 %arg1, i32 %arg2) {
130 %A = shl i32 %arg1, %arg2
134 define i32 @shl_i32_2(i32 %arg1, i32 %arg2) {
135 %A = shl i32 %arg2, %arg1
139 define i32 @shl_i32_3(i32 signext %arg1, i32 signext %arg2) signext {
140 %A = shl i32 %arg1, %arg2
144 define i32 @shl_i32_4(i32 signext %arg1, i32 signext %arg2) signext {
145 %A = shl i32 %arg2, %arg1
149 define i32 @shl_i32_5(i32 zeroext %arg1, i32 zeroext %arg2) zeroext {
150 %A = shl i32 %arg1, %arg2
154 define i32 @shl_i32_6(i32 zeroext %arg1, i32 zeroext %arg2) zeroext {
155 %A = shl i32 %arg2, %arg1
159 ; Shift left i32 with immediate:
160 define i32 @shli_i32_1(i32 %arg1) {
161 %A = shl i32 %arg1, 12
165 ; Should not generate anything other than the return, arg1 << 0 = arg1
166 define i32 @shli_i32_2(i32 %arg1) {
167 %A = shl i32 %arg1, 0
171 define i32 @shli_i32_3(i32 %arg1) {
172 %A = shl i32 16383, %arg1
176 ; Should generate 0, 0 << arg1 = 0
177 define i32 @shli_i32_4(i32 %arg1) {
178 %A = shl i32 0, %arg1
182 define i32 @shli_i32_5(i32 signext %arg1) signext {
183 %A = shl i32 %arg1, 12
187 ; Should not generate anything other than the return, arg1 << 0 = arg1
188 define i32 @shli_i32_6(i32 signext %arg1) signext {
189 %A = shl i32 %arg1, 0
193 define i32 @shli_i32_7(i32 signext %arg1) signext {
194 %A = shl i32 16383, %arg1
198 ; Should generate 0, 0 << arg1 = 0
199 define i32 @shli_i32_8(i32 signext %arg1) signext {
200 %A = shl i32 0, %arg1
204 define i32 @shli_i32_9(i32 zeroext %arg1) zeroext {
205 %A = shl i32 %arg1, 12
209 ; Should not generate anything other than the return, arg1 << 0 = arg1
210 define i32 @shli_i32_10(i32 zeroext %arg1) zeroext {
211 %A = shl i32 %arg1, 0
215 define i32 @shli_i32_11(i32 zeroext %arg1) zeroext {
216 %A = shl i32 16383, %arg1
220 ; Should generate 0, 0 << arg1 = 0
221 define i32 @shli_i32_12(i32 zeroext %arg1) zeroext {
222 %A = shl i32 0, %arg1
228 define i64 @shl_i64_1(i64 %arg1) {
229 %A = shl i64 %arg1, 9
233 define i64 @shl_i64_2(i64 %arg1) {
234 %A = shl i64 %arg1, 3
238 define i64 @shl_i64_3(i64 %arg1, i32 %shift) {
239 %1 = zext i32 %shift to i64
240 %2 = shl i64 %arg1, %1
244 ;; i64 shift right logical (shift 0s from the right)
246 define i64 @lshr_i64_1(i64 %arg1) {
247 %1 = lshr i64 %arg1, 9
251 define i64 @lshr_i64_2(i64 %arg1) {
252 %1 = lshr i64 %arg1, 3
256 define i64 @lshr_i64_3(i64 %arg1, i32 %shift) {
257 %1 = zext i32 %shift to i64
258 %2 = lshr i64 %arg1, %1
262 ;; i64 shift right arithmetic (shift 1s from the right)
264 define i64 @ashr_i64_1(i64 %arg) {
265 %1 = ashr i64 %arg, 9
269 define i64 @ashr_i64_2(i64 %arg) {
270 %1 = ashr i64 %arg, 3
274 define i64 @ashr_i64_3(i64 %arg1, i32 %shift) {
275 %1 = zext i32 %shift to i64
276 %2 = ashr i64 %arg1, %1
280 define i32 @hi32_i64(i64 %arg) {
281 %1 = lshr i64 %arg, 32
282 %2 = trunc i64 %1 to i32
287 define i128 @test_lshr_i128( i128 %val ) {
288 ;CHECK: test_lshr_i128
293 %rv = lshr i128 %val, 64