1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefix=RV32I
4 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
5 ; RUN: | FileCheck %s -check-prefix=RV64I
7 ; Basic shift support is tested as part of ALU.ll. This file ensures that
8 ; shifts which may not be supported natively are lowered properly.
10 declare i64 @llvm.fshr.i64(i64, i64, i64)
11 declare i128 @llvm.fshr.i128(i128, i128, i128)
13 define i64 @lshr64(i64 %a, i64 %b) nounwind {
14 ; RV32I-LABEL: lshr64:
16 ; RV32I-NEXT: addi a4, a2, -32
17 ; RV32I-NEXT: srl a3, a1, a2
18 ; RV32I-NEXT: bltz a4, .LBB0_2
19 ; RV32I-NEXT: # %bb.1:
20 ; RV32I-NEXT: mv a0, a3
21 ; RV32I-NEXT: j .LBB0_3
22 ; RV32I-NEXT: .LBB0_2:
23 ; RV32I-NEXT: srl a0, a0, a2
24 ; RV32I-NEXT: not a2, a2
25 ; RV32I-NEXT: slli a1, a1, 1
26 ; RV32I-NEXT: sll a1, a1, a2
27 ; RV32I-NEXT: or a0, a0, a1
28 ; RV32I-NEXT: .LBB0_3:
29 ; RV32I-NEXT: srai a1, a4, 31
30 ; RV32I-NEXT: and a1, a1, a3
33 ; RV64I-LABEL: lshr64:
35 ; RV64I-NEXT: srl a0, a0, a1
41 define i64 @lshr64_minsize(i64 %a, i64 %b) minsize nounwind {
42 ; RV32I-LABEL: lshr64_minsize:
44 ; RV32I-NEXT: addi sp, sp, -16
45 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
46 ; RV32I-NEXT: call __lshrdi3
47 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
48 ; RV32I-NEXT: addi sp, sp, 16
51 ; RV64I-LABEL: lshr64_minsize:
53 ; RV64I-NEXT: srl a0, a0, a1
59 define i64 @ashr64(i64 %a, i64 %b) nounwind {
60 ; RV32I-LABEL: ashr64:
62 ; RV32I-NEXT: mv a3, a1
63 ; RV32I-NEXT: addi a4, a2, -32
64 ; RV32I-NEXT: sra a1, a1, a2
65 ; RV32I-NEXT: bltz a4, .LBB2_2
66 ; RV32I-NEXT: # %bb.1:
67 ; RV32I-NEXT: srai a3, a3, 31
68 ; RV32I-NEXT: mv a0, a1
69 ; RV32I-NEXT: mv a1, a3
71 ; RV32I-NEXT: .LBB2_2:
72 ; RV32I-NEXT: srl a0, a0, a2
73 ; RV32I-NEXT: not a2, a2
74 ; RV32I-NEXT: slli a3, a3, 1
75 ; RV32I-NEXT: sll a2, a3, a2
76 ; RV32I-NEXT: or a0, a0, a2
79 ; RV64I-LABEL: ashr64:
81 ; RV64I-NEXT: sra a0, a0, a1
87 define i64 @ashr64_minsize(i64 %a, i64 %b) minsize nounwind {
88 ; RV32I-LABEL: ashr64_minsize:
90 ; RV32I-NEXT: addi sp, sp, -16
91 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
92 ; RV32I-NEXT: call __ashrdi3
93 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
94 ; RV32I-NEXT: addi sp, sp, 16
97 ; RV64I-LABEL: ashr64_minsize:
99 ; RV64I-NEXT: sra a0, a0, a1
105 define i64 @shl64(i64 %a, i64 %b) nounwind {
106 ; RV32I-LABEL: shl64:
108 ; RV32I-NEXT: addi a4, a2, -32
109 ; RV32I-NEXT: sll a3, a0, a2
110 ; RV32I-NEXT: bltz a4, .LBB4_2
111 ; RV32I-NEXT: # %bb.1:
112 ; RV32I-NEXT: mv a1, a3
113 ; RV32I-NEXT: j .LBB4_3
114 ; RV32I-NEXT: .LBB4_2:
115 ; RV32I-NEXT: sll a1, a1, a2
116 ; RV32I-NEXT: not a2, a2
117 ; RV32I-NEXT: srli a0, a0, 1
118 ; RV32I-NEXT: srl a0, a0, a2
119 ; RV32I-NEXT: or a1, a1, a0
120 ; RV32I-NEXT: .LBB4_3:
121 ; RV32I-NEXT: srai a0, a4, 31
122 ; RV32I-NEXT: and a0, a0, a3
125 ; RV64I-LABEL: shl64:
127 ; RV64I-NEXT: sll a0, a0, a1
133 define i64 @shl64_minsize(i64 %a, i64 %b) minsize nounwind {
134 ; RV32I-LABEL: shl64_minsize:
136 ; RV32I-NEXT: addi sp, sp, -16
137 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
138 ; RV32I-NEXT: call __ashldi3
139 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
140 ; RV32I-NEXT: addi sp, sp, 16
143 ; RV64I-LABEL: shl64_minsize:
145 ; RV64I-NEXT: sll a0, a0, a1
151 define i128 @lshr128(i128 %a, i128 %b) nounwind {
152 ; RV32I-LABEL: lshr128:
154 ; RV32I-NEXT: addi sp, sp, -32
155 ; RV32I-NEXT: lw a2, 0(a2)
156 ; RV32I-NEXT: lw a3, 0(a1)
157 ; RV32I-NEXT: lw a4, 4(a1)
158 ; RV32I-NEXT: lw a5, 8(a1)
159 ; RV32I-NEXT: lw a1, 12(a1)
160 ; RV32I-NEXT: sb zero, 31(sp)
161 ; RV32I-NEXT: sb zero, 30(sp)
162 ; RV32I-NEXT: sb zero, 29(sp)
163 ; RV32I-NEXT: sb zero, 28(sp)
164 ; RV32I-NEXT: sb zero, 27(sp)
165 ; RV32I-NEXT: sb zero, 26(sp)
166 ; RV32I-NEXT: sb zero, 25(sp)
167 ; RV32I-NEXT: sb zero, 24(sp)
168 ; RV32I-NEXT: sb zero, 23(sp)
169 ; RV32I-NEXT: sb zero, 22(sp)
170 ; RV32I-NEXT: sb zero, 21(sp)
171 ; RV32I-NEXT: sb zero, 20(sp)
172 ; RV32I-NEXT: sb zero, 19(sp)
173 ; RV32I-NEXT: sb zero, 18(sp)
174 ; RV32I-NEXT: sb zero, 17(sp)
175 ; RV32I-NEXT: sb zero, 16(sp)
176 ; RV32I-NEXT: sb a1, 12(sp)
177 ; RV32I-NEXT: sb a5, 8(sp)
178 ; RV32I-NEXT: sb a4, 4(sp)
179 ; RV32I-NEXT: sb a3, 0(sp)
180 ; RV32I-NEXT: srli a6, a1, 24
181 ; RV32I-NEXT: sb a6, 15(sp)
182 ; RV32I-NEXT: srli a6, a1, 16
183 ; RV32I-NEXT: sb a6, 14(sp)
184 ; RV32I-NEXT: srli a1, a1, 8
185 ; RV32I-NEXT: sb a1, 13(sp)
186 ; RV32I-NEXT: srli a1, a5, 24
187 ; RV32I-NEXT: sb a1, 11(sp)
188 ; RV32I-NEXT: srli a1, a5, 16
189 ; RV32I-NEXT: sb a1, 10(sp)
190 ; RV32I-NEXT: srli a5, a5, 8
191 ; RV32I-NEXT: sb a5, 9(sp)
192 ; RV32I-NEXT: srli a1, a4, 24
193 ; RV32I-NEXT: sb a1, 7(sp)
194 ; RV32I-NEXT: srli a1, a4, 16
195 ; RV32I-NEXT: sb a1, 6(sp)
196 ; RV32I-NEXT: srli a4, a4, 8
197 ; RV32I-NEXT: sb a4, 5(sp)
198 ; RV32I-NEXT: srli a1, a3, 24
199 ; RV32I-NEXT: sb a1, 3(sp)
200 ; RV32I-NEXT: srli a1, a3, 16
201 ; RV32I-NEXT: sb a1, 2(sp)
202 ; RV32I-NEXT: srli a3, a3, 8
203 ; RV32I-NEXT: sb a3, 1(sp)
204 ; RV32I-NEXT: slli a1, a2, 25
205 ; RV32I-NEXT: srli a1, a1, 28
206 ; RV32I-NEXT: mv a3, sp
207 ; RV32I-NEXT: add a1, a3, a1
208 ; RV32I-NEXT: lbu a3, 1(a1)
209 ; RV32I-NEXT: lbu a4, 0(a1)
210 ; RV32I-NEXT: lbu a5, 2(a1)
211 ; RV32I-NEXT: lbu a6, 3(a1)
212 ; RV32I-NEXT: slli a3, a3, 8
213 ; RV32I-NEXT: or a3, a3, a4
214 ; RV32I-NEXT: slli a5, a5, 16
215 ; RV32I-NEXT: slli a6, a6, 24
216 ; RV32I-NEXT: or a4, a6, a5
217 ; RV32I-NEXT: or a3, a4, a3
218 ; RV32I-NEXT: andi a2, a2, 7
219 ; RV32I-NEXT: srl a3, a3, a2
220 ; RV32I-NEXT: lbu a4, 5(a1)
221 ; RV32I-NEXT: lbu a5, 4(a1)
222 ; RV32I-NEXT: lbu a6, 6(a1)
223 ; RV32I-NEXT: lbu a7, 7(a1)
224 ; RV32I-NEXT: slli a4, a4, 8
225 ; RV32I-NEXT: or a4, a4, a5
226 ; RV32I-NEXT: slli a6, a6, 16
227 ; RV32I-NEXT: slli a7, a7, 24
228 ; RV32I-NEXT: or a5, a7, a6
229 ; RV32I-NEXT: or a4, a5, a4
230 ; RV32I-NEXT: slli a5, a4, 1
231 ; RV32I-NEXT: xori a6, a2, 31
232 ; RV32I-NEXT: sll a5, a5, a6
233 ; RV32I-NEXT: or a3, a3, a5
234 ; RV32I-NEXT: srl a4, a4, a2
235 ; RV32I-NEXT: lbu a5, 9(a1)
236 ; RV32I-NEXT: lbu a7, 8(a1)
237 ; RV32I-NEXT: lbu t0, 10(a1)
238 ; RV32I-NEXT: lbu t1, 11(a1)
239 ; RV32I-NEXT: slli a5, a5, 8
240 ; RV32I-NEXT: or a5, a5, a7
241 ; RV32I-NEXT: slli t0, t0, 16
242 ; RV32I-NEXT: slli t1, t1, 24
243 ; RV32I-NEXT: or a7, t1, t0
244 ; RV32I-NEXT: or a5, a7, a5
245 ; RV32I-NEXT: slli a7, a5, 1
246 ; RV32I-NEXT: not t0, a2
247 ; RV32I-NEXT: lbu t1, 13(a1)
248 ; RV32I-NEXT: sll a7, a7, t0
249 ; RV32I-NEXT: or a4, a4, a7
250 ; RV32I-NEXT: lbu a7, 12(a1)
251 ; RV32I-NEXT: slli t1, t1, 8
252 ; RV32I-NEXT: lbu t0, 14(a1)
253 ; RV32I-NEXT: lbu a1, 15(a1)
254 ; RV32I-NEXT: or a7, t1, a7
255 ; RV32I-NEXT: srl a5, a5, a2
256 ; RV32I-NEXT: slli t0, t0, 16
257 ; RV32I-NEXT: slli a1, a1, 24
258 ; RV32I-NEXT: or a1, a1, t0
259 ; RV32I-NEXT: or a1, a1, a7
260 ; RV32I-NEXT: slli a7, a1, 1
261 ; RV32I-NEXT: sll a6, a7, a6
262 ; RV32I-NEXT: or a5, a5, a6
263 ; RV32I-NEXT: srl a1, a1, a2
264 ; RV32I-NEXT: sw a1, 12(a0)
265 ; RV32I-NEXT: sw a5, 8(a0)
266 ; RV32I-NEXT: sw a4, 4(a0)
267 ; RV32I-NEXT: sw a3, 0(a0)
268 ; RV32I-NEXT: addi sp, sp, 32
271 ; RV64I-LABEL: lshr128:
273 ; RV64I-NEXT: addi a4, a2, -64
274 ; RV64I-NEXT: srl a3, a1, a2
275 ; RV64I-NEXT: bltz a4, .LBB6_2
276 ; RV64I-NEXT: # %bb.1:
277 ; RV64I-NEXT: mv a0, a3
278 ; RV64I-NEXT: j .LBB6_3
279 ; RV64I-NEXT: .LBB6_2:
280 ; RV64I-NEXT: srl a0, a0, a2
281 ; RV64I-NEXT: not a2, a2
282 ; RV64I-NEXT: slli a1, a1, 1
283 ; RV64I-NEXT: sll a1, a1, a2
284 ; RV64I-NEXT: or a0, a0, a1
285 ; RV64I-NEXT: .LBB6_3:
286 ; RV64I-NEXT: srai a1, a4, 63
287 ; RV64I-NEXT: and a1, a1, a3
289 %1 = lshr i128 %a, %b
293 define i128 @ashr128(i128 %a, i128 %b) nounwind {
294 ; RV32I-LABEL: ashr128:
296 ; RV32I-NEXT: addi sp, sp, -32
297 ; RV32I-NEXT: lw a2, 0(a2)
298 ; RV32I-NEXT: lw a3, 12(a1)
299 ; RV32I-NEXT: lw a4, 8(a1)
300 ; RV32I-NEXT: lw a5, 4(a1)
301 ; RV32I-NEXT: lw a1, 0(a1)
302 ; RV32I-NEXT: sb a3, 12(sp)
303 ; RV32I-NEXT: sb a4, 8(sp)
304 ; RV32I-NEXT: sb a5, 4(sp)
305 ; RV32I-NEXT: sb a1, 0(sp)
306 ; RV32I-NEXT: srai a6, a3, 31
307 ; RV32I-NEXT: sb a6, 28(sp)
308 ; RV32I-NEXT: sb a6, 24(sp)
309 ; RV32I-NEXT: sb a6, 20(sp)
310 ; RV32I-NEXT: sb a6, 16(sp)
311 ; RV32I-NEXT: srli a7, a3, 24
312 ; RV32I-NEXT: sb a7, 15(sp)
313 ; RV32I-NEXT: srli a7, a3, 16
314 ; RV32I-NEXT: sb a7, 14(sp)
315 ; RV32I-NEXT: srli a3, a3, 8
316 ; RV32I-NEXT: sb a3, 13(sp)
317 ; RV32I-NEXT: srli a3, a4, 24
318 ; RV32I-NEXT: sb a3, 11(sp)
319 ; RV32I-NEXT: srli a3, a4, 16
320 ; RV32I-NEXT: sb a3, 10(sp)
321 ; RV32I-NEXT: srli a4, a4, 8
322 ; RV32I-NEXT: sb a4, 9(sp)
323 ; RV32I-NEXT: srli a3, a5, 24
324 ; RV32I-NEXT: sb a3, 7(sp)
325 ; RV32I-NEXT: srli a3, a5, 16
326 ; RV32I-NEXT: sb a3, 6(sp)
327 ; RV32I-NEXT: srli a5, a5, 8
328 ; RV32I-NEXT: sb a5, 5(sp)
329 ; RV32I-NEXT: srli a3, a1, 24
330 ; RV32I-NEXT: sb a3, 3(sp)
331 ; RV32I-NEXT: srli a3, a1, 16
332 ; RV32I-NEXT: sb a3, 2(sp)
333 ; RV32I-NEXT: srli a1, a1, 8
334 ; RV32I-NEXT: sb a1, 1(sp)
335 ; RV32I-NEXT: srli a1, a6, 24
336 ; RV32I-NEXT: sb a1, 31(sp)
337 ; RV32I-NEXT: srli a3, a6, 16
338 ; RV32I-NEXT: sb a3, 30(sp)
339 ; RV32I-NEXT: srli a4, a6, 8
340 ; RV32I-NEXT: sb a4, 29(sp)
341 ; RV32I-NEXT: sb a1, 27(sp)
342 ; RV32I-NEXT: sb a3, 26(sp)
343 ; RV32I-NEXT: sb a4, 25(sp)
344 ; RV32I-NEXT: sb a1, 23(sp)
345 ; RV32I-NEXT: sb a3, 22(sp)
346 ; RV32I-NEXT: sb a4, 21(sp)
347 ; RV32I-NEXT: sb a1, 19(sp)
348 ; RV32I-NEXT: sb a3, 18(sp)
349 ; RV32I-NEXT: sb a4, 17(sp)
350 ; RV32I-NEXT: slli a1, a2, 25
351 ; RV32I-NEXT: srli a1, a1, 28
352 ; RV32I-NEXT: mv a3, sp
353 ; RV32I-NEXT: add a1, a3, a1
354 ; RV32I-NEXT: lbu a3, 1(a1)
355 ; RV32I-NEXT: lbu a4, 0(a1)
356 ; RV32I-NEXT: lbu a5, 2(a1)
357 ; RV32I-NEXT: lbu a6, 3(a1)
358 ; RV32I-NEXT: slli a3, a3, 8
359 ; RV32I-NEXT: or a3, a3, a4
360 ; RV32I-NEXT: slli a5, a5, 16
361 ; RV32I-NEXT: slli a6, a6, 24
362 ; RV32I-NEXT: or a4, a6, a5
363 ; RV32I-NEXT: or a3, a4, a3
364 ; RV32I-NEXT: andi a2, a2, 7
365 ; RV32I-NEXT: srl a3, a3, a2
366 ; RV32I-NEXT: lbu a4, 5(a1)
367 ; RV32I-NEXT: lbu a5, 4(a1)
368 ; RV32I-NEXT: lbu a6, 6(a1)
369 ; RV32I-NEXT: lbu a7, 7(a1)
370 ; RV32I-NEXT: slli a4, a4, 8
371 ; RV32I-NEXT: or a4, a4, a5
372 ; RV32I-NEXT: slli a6, a6, 16
373 ; RV32I-NEXT: slli a7, a7, 24
374 ; RV32I-NEXT: or a5, a7, a6
375 ; RV32I-NEXT: or a4, a5, a4
376 ; RV32I-NEXT: slli a5, a4, 1
377 ; RV32I-NEXT: xori a6, a2, 31
378 ; RV32I-NEXT: sll a5, a5, a6
379 ; RV32I-NEXT: or a3, a3, a5
380 ; RV32I-NEXT: srl a4, a4, a2
381 ; RV32I-NEXT: lbu a5, 9(a1)
382 ; RV32I-NEXT: lbu a7, 8(a1)
383 ; RV32I-NEXT: lbu t0, 10(a1)
384 ; RV32I-NEXT: lbu t1, 11(a1)
385 ; RV32I-NEXT: slli a5, a5, 8
386 ; RV32I-NEXT: or a5, a5, a7
387 ; RV32I-NEXT: slli t0, t0, 16
388 ; RV32I-NEXT: slli t1, t1, 24
389 ; RV32I-NEXT: or a7, t1, t0
390 ; RV32I-NEXT: or a5, a7, a5
391 ; RV32I-NEXT: slli a7, a5, 1
392 ; RV32I-NEXT: not t0, a2
393 ; RV32I-NEXT: lbu t1, 13(a1)
394 ; RV32I-NEXT: sll a7, a7, t0
395 ; RV32I-NEXT: or a4, a4, a7
396 ; RV32I-NEXT: lbu a7, 12(a1)
397 ; RV32I-NEXT: slli t1, t1, 8
398 ; RV32I-NEXT: lbu t0, 14(a1)
399 ; RV32I-NEXT: lbu a1, 15(a1)
400 ; RV32I-NEXT: or a7, t1, a7
401 ; RV32I-NEXT: srl a5, a5, a2
402 ; RV32I-NEXT: slli t0, t0, 16
403 ; RV32I-NEXT: slli a1, a1, 24
404 ; RV32I-NEXT: or a1, a1, t0
405 ; RV32I-NEXT: or a1, a1, a7
406 ; RV32I-NEXT: slli a7, a1, 1
407 ; RV32I-NEXT: sll a6, a7, a6
408 ; RV32I-NEXT: or a5, a5, a6
409 ; RV32I-NEXT: sra a1, a1, a2
410 ; RV32I-NEXT: sw a1, 12(a0)
411 ; RV32I-NEXT: sw a5, 8(a0)
412 ; RV32I-NEXT: sw a4, 4(a0)
413 ; RV32I-NEXT: sw a3, 0(a0)
414 ; RV32I-NEXT: addi sp, sp, 32
417 ; RV64I-LABEL: ashr128:
419 ; RV64I-NEXT: mv a3, a1
420 ; RV64I-NEXT: addi a4, a2, -64
421 ; RV64I-NEXT: sra a1, a1, a2
422 ; RV64I-NEXT: bltz a4, .LBB7_2
423 ; RV64I-NEXT: # %bb.1:
424 ; RV64I-NEXT: srai a3, a3, 63
425 ; RV64I-NEXT: mv a0, a1
426 ; RV64I-NEXT: mv a1, a3
428 ; RV64I-NEXT: .LBB7_2:
429 ; RV64I-NEXT: srl a0, a0, a2
430 ; RV64I-NEXT: not a2, a2
431 ; RV64I-NEXT: slli a3, a3, 1
432 ; RV64I-NEXT: sll a2, a3, a2
433 ; RV64I-NEXT: or a0, a0, a2
435 %1 = ashr i128 %a, %b
439 define i128 @shl128(i128 %a, i128 %b) nounwind {
440 ; RV32I-LABEL: shl128:
442 ; RV32I-NEXT: addi sp, sp, -32
443 ; RV32I-NEXT: lw a2, 0(a2)
444 ; RV32I-NEXT: lw a3, 0(a1)
445 ; RV32I-NEXT: lw a4, 4(a1)
446 ; RV32I-NEXT: lw a5, 8(a1)
447 ; RV32I-NEXT: lw a1, 12(a1)
448 ; RV32I-NEXT: sb zero, 15(sp)
449 ; RV32I-NEXT: sb zero, 14(sp)
450 ; RV32I-NEXT: sb zero, 13(sp)
451 ; RV32I-NEXT: sb zero, 12(sp)
452 ; RV32I-NEXT: sb zero, 11(sp)
453 ; RV32I-NEXT: sb zero, 10(sp)
454 ; RV32I-NEXT: sb zero, 9(sp)
455 ; RV32I-NEXT: sb zero, 8(sp)
456 ; RV32I-NEXT: sb zero, 7(sp)
457 ; RV32I-NEXT: sb zero, 6(sp)
458 ; RV32I-NEXT: sb zero, 5(sp)
459 ; RV32I-NEXT: sb zero, 4(sp)
460 ; RV32I-NEXT: sb zero, 3(sp)
461 ; RV32I-NEXT: sb zero, 2(sp)
462 ; RV32I-NEXT: sb zero, 1(sp)
463 ; RV32I-NEXT: sb zero, 0(sp)
464 ; RV32I-NEXT: sb a1, 28(sp)
465 ; RV32I-NEXT: sb a5, 24(sp)
466 ; RV32I-NEXT: sb a4, 20(sp)
467 ; RV32I-NEXT: sb a3, 16(sp)
468 ; RV32I-NEXT: srli a6, a1, 24
469 ; RV32I-NEXT: sb a6, 31(sp)
470 ; RV32I-NEXT: srli a6, a1, 16
471 ; RV32I-NEXT: sb a6, 30(sp)
472 ; RV32I-NEXT: srli a1, a1, 8
473 ; RV32I-NEXT: sb a1, 29(sp)
474 ; RV32I-NEXT: srli a1, a5, 24
475 ; RV32I-NEXT: sb a1, 27(sp)
476 ; RV32I-NEXT: srli a1, a5, 16
477 ; RV32I-NEXT: sb a1, 26(sp)
478 ; RV32I-NEXT: srli a5, a5, 8
479 ; RV32I-NEXT: sb a5, 25(sp)
480 ; RV32I-NEXT: srli a1, a4, 24
481 ; RV32I-NEXT: sb a1, 23(sp)
482 ; RV32I-NEXT: srli a1, a4, 16
483 ; RV32I-NEXT: sb a1, 22(sp)
484 ; RV32I-NEXT: srli a4, a4, 8
485 ; RV32I-NEXT: sb a4, 21(sp)
486 ; RV32I-NEXT: srli a1, a3, 24
487 ; RV32I-NEXT: sb a1, 19(sp)
488 ; RV32I-NEXT: srli a1, a3, 16
489 ; RV32I-NEXT: sb a1, 18(sp)
490 ; RV32I-NEXT: srli a3, a3, 8
491 ; RV32I-NEXT: sb a3, 17(sp)
492 ; RV32I-NEXT: slli a1, a2, 25
493 ; RV32I-NEXT: srli a1, a1, 28
494 ; RV32I-NEXT: addi a3, sp, 16
495 ; RV32I-NEXT: sub a1, a3, a1
496 ; RV32I-NEXT: lbu a3, 5(a1)
497 ; RV32I-NEXT: lbu a4, 4(a1)
498 ; RV32I-NEXT: lbu a5, 6(a1)
499 ; RV32I-NEXT: lbu a6, 7(a1)
500 ; RV32I-NEXT: slli a3, a3, 8
501 ; RV32I-NEXT: or a3, a3, a4
502 ; RV32I-NEXT: slli a5, a5, 16
503 ; RV32I-NEXT: slli a6, a6, 24
504 ; RV32I-NEXT: or a4, a6, a5
505 ; RV32I-NEXT: or a3, a4, a3
506 ; RV32I-NEXT: andi a2, a2, 7
507 ; RV32I-NEXT: sll a4, a3, a2
508 ; RV32I-NEXT: lbu a5, 1(a1)
509 ; RV32I-NEXT: lbu a6, 0(a1)
510 ; RV32I-NEXT: lbu a7, 2(a1)
511 ; RV32I-NEXT: lbu t0, 3(a1)
512 ; RV32I-NEXT: slli a5, a5, 8
513 ; RV32I-NEXT: or a5, a5, a6
514 ; RV32I-NEXT: slli a7, a7, 16
515 ; RV32I-NEXT: slli t0, t0, 24
516 ; RV32I-NEXT: or a6, t0, a7
517 ; RV32I-NEXT: or a5, a6, a5
518 ; RV32I-NEXT: srli a6, a5, 1
519 ; RV32I-NEXT: xori a7, a2, 31
520 ; RV32I-NEXT: srl a6, a6, a7
521 ; RV32I-NEXT: or a4, a4, a6
522 ; RV32I-NEXT: lbu a6, 9(a1)
523 ; RV32I-NEXT: lbu t0, 8(a1)
524 ; RV32I-NEXT: lbu t1, 10(a1)
525 ; RV32I-NEXT: lbu t2, 11(a1)
526 ; RV32I-NEXT: slli a6, a6, 8
527 ; RV32I-NEXT: or a6, a6, t0
528 ; RV32I-NEXT: slli t1, t1, 16
529 ; RV32I-NEXT: slli t2, t2, 24
530 ; RV32I-NEXT: or t0, t2, t1
531 ; RV32I-NEXT: or a6, t0, a6
532 ; RV32I-NEXT: sll t0, a6, a2
533 ; RV32I-NEXT: srli a3, a3, 1
534 ; RV32I-NEXT: not t1, a2
535 ; RV32I-NEXT: srl a3, a3, t1
536 ; RV32I-NEXT: or a3, t0, a3
537 ; RV32I-NEXT: lbu t0, 13(a1)
538 ; RV32I-NEXT: lbu t1, 12(a1)
539 ; RV32I-NEXT: lbu t2, 14(a1)
540 ; RV32I-NEXT: lbu a1, 15(a1)
541 ; RV32I-NEXT: slli t0, t0, 8
542 ; RV32I-NEXT: or t0, t0, t1
543 ; RV32I-NEXT: slli t2, t2, 16
544 ; RV32I-NEXT: slli a1, a1, 24
545 ; RV32I-NEXT: or a1, a1, t2
546 ; RV32I-NEXT: or a1, a1, t0
547 ; RV32I-NEXT: sll a1, a1, a2
548 ; RV32I-NEXT: srli a6, a6, 1
549 ; RV32I-NEXT: srl a6, a6, a7
550 ; RV32I-NEXT: or a1, a1, a6
551 ; RV32I-NEXT: sll a2, a5, a2
552 ; RV32I-NEXT: sw a2, 0(a0)
553 ; RV32I-NEXT: sw a1, 12(a0)
554 ; RV32I-NEXT: sw a3, 8(a0)
555 ; RV32I-NEXT: sw a4, 4(a0)
556 ; RV32I-NEXT: addi sp, sp, 32
559 ; RV64I-LABEL: shl128:
561 ; RV64I-NEXT: addi a4, a2, -64
562 ; RV64I-NEXT: sll a3, a0, a2
563 ; RV64I-NEXT: bltz a4, .LBB8_2
564 ; RV64I-NEXT: # %bb.1:
565 ; RV64I-NEXT: mv a1, a3
566 ; RV64I-NEXT: j .LBB8_3
567 ; RV64I-NEXT: .LBB8_2:
568 ; RV64I-NEXT: sll a1, a1, a2
569 ; RV64I-NEXT: not a2, a2
570 ; RV64I-NEXT: srli a0, a0, 1
571 ; RV64I-NEXT: srl a0, a0, a2
572 ; RV64I-NEXT: or a1, a1, a0
573 ; RV64I-NEXT: .LBB8_3:
574 ; RV64I-NEXT: srai a0, a4, 63
575 ; RV64I-NEXT: and a0, a0, a3
581 define i64 @fshr64_minsize(i64 %a, i64 %b) minsize nounwind {
582 ; RV32I-LABEL: fshr64_minsize:
584 ; RV32I-NEXT: andi a4, a2, 32
585 ; RV32I-NEXT: mv a3, a0
586 ; RV32I-NEXT: beqz a4, .LBB9_2
587 ; RV32I-NEXT: # %bb.1:
588 ; RV32I-NEXT: mv a3, a1
589 ; RV32I-NEXT: .LBB9_2:
590 ; RV32I-NEXT: srl a5, a3, a2
591 ; RV32I-NEXT: beqz a4, .LBB9_4
592 ; RV32I-NEXT: # %bb.3:
593 ; RV32I-NEXT: mv a1, a0
594 ; RV32I-NEXT: .LBB9_4:
595 ; RV32I-NEXT: slli a0, a1, 1
596 ; RV32I-NEXT: not a4, a2
597 ; RV32I-NEXT: sll a0, a0, a4
598 ; RV32I-NEXT: or a0, a0, a5
599 ; RV32I-NEXT: srl a1, a1, a2
600 ; RV32I-NEXT: slli a3, a3, 1
601 ; RV32I-NEXT: sll a2, a3, a4
602 ; RV32I-NEXT: or a1, a2, a1
605 ; RV64I-LABEL: fshr64_minsize:
607 ; RV64I-NEXT: srl a2, a0, a1
608 ; RV64I-NEXT: negw a1, a1
609 ; RV64I-NEXT: sll a0, a0, a1
610 ; RV64I-NEXT: or a0, a2, a0
612 %res = tail call i64 @llvm.fshr.i64(i64 %a, i64 %a, i64 %b)
616 define i128 @fshr128_minsize(i128 %a, i128 %b) minsize nounwind {
617 ; RV32I-LABEL: fshr128_minsize:
619 ; RV32I-NEXT: lw a3, 8(a1)
620 ; RV32I-NEXT: lw t2, 0(a1)
621 ; RV32I-NEXT: lw a2, 0(a2)
622 ; RV32I-NEXT: lw a7, 4(a1)
623 ; RV32I-NEXT: lw a1, 12(a1)
624 ; RV32I-NEXT: andi t1, a2, 64
625 ; RV32I-NEXT: mv t0, a7
626 ; RV32I-NEXT: mv a4, t2
627 ; RV32I-NEXT: beqz t1, .LBB10_2
628 ; RV32I-NEXT: # %bb.1:
629 ; RV32I-NEXT: mv t0, a1
630 ; RV32I-NEXT: mv a4, a3
631 ; RV32I-NEXT: .LBB10_2:
632 ; RV32I-NEXT: andi a6, a2, 32
633 ; RV32I-NEXT: mv a5, a4
634 ; RV32I-NEXT: bnez a6, .LBB10_13
635 ; RV32I-NEXT: # %bb.3:
636 ; RV32I-NEXT: bnez t1, .LBB10_14
637 ; RV32I-NEXT: .LBB10_4:
638 ; RV32I-NEXT: beqz a6, .LBB10_6
639 ; RV32I-NEXT: .LBB10_5:
640 ; RV32I-NEXT: mv t0, a3
641 ; RV32I-NEXT: .LBB10_6:
642 ; RV32I-NEXT: slli t3, t0, 1
643 ; RV32I-NEXT: not t2, a2
644 ; RV32I-NEXT: beqz t1, .LBB10_8
645 ; RV32I-NEXT: # %bb.7:
646 ; RV32I-NEXT: mv a1, a7
647 ; RV32I-NEXT: .LBB10_8:
648 ; RV32I-NEXT: srl a7, a5, a2
649 ; RV32I-NEXT: sll t1, t3, t2
650 ; RV32I-NEXT: srl t0, t0, a2
651 ; RV32I-NEXT: beqz a6, .LBB10_10
652 ; RV32I-NEXT: # %bb.9:
653 ; RV32I-NEXT: mv a3, a1
654 ; RV32I-NEXT: .LBB10_10:
655 ; RV32I-NEXT: or a7, t1, a7
656 ; RV32I-NEXT: slli t1, a3, 1
657 ; RV32I-NEXT: sll t1, t1, t2
658 ; RV32I-NEXT: or t0, t1, t0
659 ; RV32I-NEXT: srl a3, a3, a2
660 ; RV32I-NEXT: beqz a6, .LBB10_12
661 ; RV32I-NEXT: # %bb.11:
662 ; RV32I-NEXT: mv a1, a4
663 ; RV32I-NEXT: .LBB10_12:
664 ; RV32I-NEXT: slli a4, a1, 1
665 ; RV32I-NEXT: sll a4, a4, t2
666 ; RV32I-NEXT: or a3, a4, a3
667 ; RV32I-NEXT: srl a1, a1, a2
668 ; RV32I-NEXT: slli a5, a5, 1
669 ; RV32I-NEXT: sll a2, a5, t2
670 ; RV32I-NEXT: or a1, a2, a1
671 ; RV32I-NEXT: sw a1, 12(a0)
672 ; RV32I-NEXT: sw a3, 8(a0)
673 ; RV32I-NEXT: sw t0, 4(a0)
674 ; RV32I-NEXT: sw a7, 0(a0)
676 ; RV32I-NEXT: .LBB10_13:
677 ; RV32I-NEXT: mv a5, t0
678 ; RV32I-NEXT: beqz t1, .LBB10_4
679 ; RV32I-NEXT: .LBB10_14:
680 ; RV32I-NEXT: mv a3, t2
681 ; RV32I-NEXT: bnez a6, .LBB10_5
682 ; RV32I-NEXT: j .LBB10_6
684 ; RV64I-LABEL: fshr128_minsize:
686 ; RV64I-NEXT: andi a4, a2, 64
687 ; RV64I-NEXT: mv a3, a0
688 ; RV64I-NEXT: beqz a4, .LBB10_2
689 ; RV64I-NEXT: # %bb.1:
690 ; RV64I-NEXT: mv a3, a1
691 ; RV64I-NEXT: .LBB10_2:
692 ; RV64I-NEXT: srl a5, a3, a2
693 ; RV64I-NEXT: beqz a4, .LBB10_4
694 ; RV64I-NEXT: # %bb.3:
695 ; RV64I-NEXT: mv a1, a0
696 ; RV64I-NEXT: .LBB10_4:
697 ; RV64I-NEXT: slli a0, a1, 1
698 ; RV64I-NEXT: not a4, a2
699 ; RV64I-NEXT: sll a0, a0, a4
700 ; RV64I-NEXT: or a0, a0, a5
701 ; RV64I-NEXT: srl a1, a1, a2
702 ; RV64I-NEXT: slli a3, a3, 1
703 ; RV64I-NEXT: sll a2, a3, a4
704 ; RV64I-NEXT: or a1, a2, a1
706 %res = tail call i128 @llvm.fshr.i128(i128 %a, i128 %a, i128 %b)