1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
3 ; RUN: -riscv-experimental-rv64-legal-i32 | FileCheck -check-prefix=RV64I %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+m -verify-machineinstrs < %s \
5 ; RUN: -riscv-experimental-rv64-legal-i32 | FileCheck -check-prefix=RV64IM %s
7 define i32 @udiv(i32 %a, i32 %b) nounwind {
10 ; RV64I-NEXT: addi sp, sp, -16
11 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
12 ; RV64I-NEXT: slli a0, a0, 32
13 ; RV64I-NEXT: srli a0, a0, 32
14 ; RV64I-NEXT: slli a1, a1, 32
15 ; RV64I-NEXT: srli a1, a1, 32
16 ; RV64I-NEXT: call __udivdi3
17 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
18 ; RV64I-NEXT: addi sp, sp, 16
23 ; RV64IM-NEXT: divuw a0, a0, a1
29 define i32 @udiv_constant(i32 %a) nounwind {
30 ; RV64I-LABEL: udiv_constant:
32 ; RV64I-NEXT: addi sp, sp, -16
33 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
34 ; RV64I-NEXT: slli a0, a0, 32
35 ; RV64I-NEXT: srli a0, a0, 32
36 ; RV64I-NEXT: li a1, 5
37 ; RV64I-NEXT: call __udivdi3
38 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
39 ; RV64I-NEXT: addi sp, sp, 16
42 ; RV64IM-LABEL: udiv_constant:
44 ; RV64IM-NEXT: slli a0, a0, 32
45 ; RV64IM-NEXT: lui a1, 838861
46 ; RV64IM-NEXT: addi a1, a1, -819
47 ; RV64IM-NEXT: slli a1, a1, 32
48 ; RV64IM-NEXT: mulhu a0, a0, a1
49 ; RV64IM-NEXT: srli a0, a0, 34
55 define i32 @udiv_pow2(i32 %a) nounwind {
56 ; RV64I-LABEL: udiv_pow2:
58 ; RV64I-NEXT: srliw a0, a0, 3
61 ; RV64IM-LABEL: udiv_pow2:
63 ; RV64IM-NEXT: srliw a0, a0, 3
69 define i32 @udiv_constant_lhs(i32 %a) nounwind {
70 ; RV64I-LABEL: udiv_constant_lhs:
72 ; RV64I-NEXT: addi sp, sp, -16
73 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
74 ; RV64I-NEXT: slli a0, a0, 32
75 ; RV64I-NEXT: srli a1, a0, 32
76 ; RV64I-NEXT: li a0, 10
77 ; RV64I-NEXT: call __udivdi3
78 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
79 ; RV64I-NEXT: addi sp, sp, 16
82 ; RV64IM-LABEL: udiv_constant_lhs:
84 ; RV64IM-NEXT: li a1, 10
85 ; RV64IM-NEXT: divuw a0, a1, a0
91 define i64 @udiv64(i64 %a, i64 %b) nounwind {
92 ; RV64I-LABEL: udiv64:
94 ; RV64I-NEXT: tail __udivdi3
96 ; RV64IM-LABEL: udiv64:
98 ; RV64IM-NEXT: divu a0, a0, a1
104 define i64 @udiv64_constant(i64 %a) nounwind {
105 ; RV64I-LABEL: udiv64_constant:
107 ; RV64I-NEXT: li a1, 5
108 ; RV64I-NEXT: tail __udivdi3
110 ; RV64IM-LABEL: udiv64_constant:
112 ; RV64IM-NEXT: lui a1, 838861
113 ; RV64IM-NEXT: addiw a1, a1, -819
114 ; RV64IM-NEXT: slli a2, a1, 32
115 ; RV64IM-NEXT: add a1, a1, a2
116 ; RV64IM-NEXT: mulhu a0, a0, a1
117 ; RV64IM-NEXT: srli a0, a0, 2
123 define i64 @udiv64_constant_lhs(i64 %a) nounwind {
124 ; RV64I-LABEL: udiv64_constant_lhs:
126 ; RV64I-NEXT: mv a1, a0
127 ; RV64I-NEXT: li a0, 10
128 ; RV64I-NEXT: tail __udivdi3
130 ; RV64IM-LABEL: udiv64_constant_lhs:
132 ; RV64IM-NEXT: li a1, 10
133 ; RV64IM-NEXT: divu a0, a1, a0
139 define i8 @udiv8(i8 %a, i8 %b) nounwind {
140 ; RV64I-LABEL: udiv8:
142 ; RV64I-NEXT: addi sp, sp, -16
143 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
144 ; RV64I-NEXT: andi a0, a0, 255
145 ; RV64I-NEXT: andi a1, a1, 255
146 ; RV64I-NEXT: call __udivdi3
147 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
148 ; RV64I-NEXT: addi sp, sp, 16
151 ; RV64IM-LABEL: udiv8:
153 ; RV64IM-NEXT: andi a1, a1, 255
154 ; RV64IM-NEXT: andi a0, a0, 255
155 ; RV64IM-NEXT: divuw a0, a0, a1
161 define i8 @udiv8_constant(i8 %a) nounwind {
162 ; RV64I-LABEL: udiv8_constant:
164 ; RV64I-NEXT: addi sp, sp, -16
165 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
166 ; RV64I-NEXT: andi a0, a0, 255
167 ; RV64I-NEXT: li a1, 5
168 ; RV64I-NEXT: call __udivdi3
169 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
170 ; RV64I-NEXT: addi sp, sp, 16
173 ; RV64IM-LABEL: udiv8_constant:
175 ; RV64IM-NEXT: andi a0, a0, 255
176 ; RV64IM-NEXT: li a1, 205
177 ; RV64IM-NEXT: mul a0, a0, a1
178 ; RV64IM-NEXT: srliw a0, a0, 10
184 define i8 @udiv8_pow2(i8 %a) nounwind {
185 ; RV64I-LABEL: udiv8_pow2:
187 ; RV64I-NEXT: slli a0, a0, 56
188 ; RV64I-NEXT: srli a0, a0, 59
191 ; RV64IM-LABEL: udiv8_pow2:
193 ; RV64IM-NEXT: slli a0, a0, 56
194 ; RV64IM-NEXT: srli a0, a0, 59
200 define i8 @udiv8_constant_lhs(i8 %a) nounwind {
201 ; RV64I-LABEL: udiv8_constant_lhs:
203 ; RV64I-NEXT: addi sp, sp, -16
204 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
205 ; RV64I-NEXT: andi a1, a0, 255
206 ; RV64I-NEXT: li a0, 10
207 ; RV64I-NEXT: call __udivdi3
208 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
209 ; RV64I-NEXT: addi sp, sp, 16
212 ; RV64IM-LABEL: udiv8_constant_lhs:
214 ; RV64IM-NEXT: andi a0, a0, 255
215 ; RV64IM-NEXT: li a1, 10
216 ; RV64IM-NEXT: divuw a0, a1, a0
222 define i16 @udiv16(i16 %a, i16 %b) nounwind {
223 ; RV64I-LABEL: udiv16:
225 ; RV64I-NEXT: addi sp, sp, -16
226 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
227 ; RV64I-NEXT: lui a2, 16
228 ; RV64I-NEXT: addiw a2, a2, -1
229 ; RV64I-NEXT: and a0, a0, a2
230 ; RV64I-NEXT: and a1, a1, a2
231 ; RV64I-NEXT: call __udivdi3
232 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
233 ; RV64I-NEXT: addi sp, sp, 16
236 ; RV64IM-LABEL: udiv16:
238 ; RV64IM-NEXT: lui a2, 16
239 ; RV64IM-NEXT: addi a2, a2, -1
240 ; RV64IM-NEXT: and a1, a1, a2
241 ; RV64IM-NEXT: and a0, a0, a2
242 ; RV64IM-NEXT: divuw a0, a0, a1
248 define i16 @udiv16_constant(i16 %a) nounwind {
249 ; RV64I-LABEL: udiv16_constant:
251 ; RV64I-NEXT: addi sp, sp, -16
252 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
253 ; RV64I-NEXT: slli a0, a0, 48
254 ; RV64I-NEXT: srli a0, a0, 48
255 ; RV64I-NEXT: li a1, 5
256 ; RV64I-NEXT: call __udivdi3
257 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
258 ; RV64I-NEXT: addi sp, sp, 16
261 ; RV64IM-LABEL: udiv16_constant:
263 ; RV64IM-NEXT: lui a1, 52429
264 ; RV64IM-NEXT: slli a1, a1, 4
265 ; RV64IM-NEXT: slli a0, a0, 48
266 ; RV64IM-NEXT: mulhu a0, a0, a1
267 ; RV64IM-NEXT: srliw a0, a0, 18
273 define i16 @udiv16_pow2(i16 %a) nounwind {
274 ; RV64I-LABEL: udiv16_pow2:
276 ; RV64I-NEXT: slli a0, a0, 48
277 ; RV64I-NEXT: srli a0, a0, 51
280 ; RV64IM-LABEL: udiv16_pow2:
282 ; RV64IM-NEXT: slli a0, a0, 48
283 ; RV64IM-NEXT: srli a0, a0, 51
289 define i16 @udiv16_constant_lhs(i16 %a) nounwind {
290 ; RV64I-LABEL: udiv16_constant_lhs:
292 ; RV64I-NEXT: addi sp, sp, -16
293 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
294 ; RV64I-NEXT: slli a0, a0, 48
295 ; RV64I-NEXT: srli a1, a0, 48
296 ; RV64I-NEXT: li a0, 10
297 ; RV64I-NEXT: call __udivdi3
298 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
299 ; RV64I-NEXT: addi sp, sp, 16
302 ; RV64IM-LABEL: udiv16_constant_lhs:
304 ; RV64IM-NEXT: slli a0, a0, 48
305 ; RV64IM-NEXT: srli a0, a0, 48
306 ; RV64IM-NEXT: li a1, 10
307 ; RV64IM-NEXT: divuw a0, a1, a0
313 define i32 @sdiv(i32 %a, i32 %b) nounwind {
316 ; RV64I-NEXT: addi sp, sp, -16
317 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
318 ; RV64I-NEXT: sext.w a0, a0
319 ; RV64I-NEXT: sext.w a1, a1
320 ; RV64I-NEXT: call __divdi3
321 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
322 ; RV64I-NEXT: addi sp, sp, 16
325 ; RV64IM-LABEL: sdiv:
327 ; RV64IM-NEXT: divw a0, a0, a1
333 define i32 @sdiv_constant(i32 %a) nounwind {
334 ; RV64I-LABEL: sdiv_constant:
336 ; RV64I-NEXT: addi sp, sp, -16
337 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
338 ; RV64I-NEXT: sext.w a0, a0
339 ; RV64I-NEXT: li a1, 5
340 ; RV64I-NEXT: call __divdi3
341 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
342 ; RV64I-NEXT: addi sp, sp, 16
345 ; RV64IM-LABEL: sdiv_constant:
347 ; RV64IM-NEXT: sext.w a0, a0
348 ; RV64IM-NEXT: lui a1, 419430
349 ; RV64IM-NEXT: addiw a1, a1, 1639
350 ; RV64IM-NEXT: mul a0, a0, a1
351 ; RV64IM-NEXT: srli a1, a0, 63
352 ; RV64IM-NEXT: srai a0, a0, 33
353 ; RV64IM-NEXT: addw a0, a0, a1
359 define i32 @sdiv_pow2(i32 %a) nounwind {
360 ; RV64I-LABEL: sdiv_pow2:
362 ; RV64I-NEXT: sraiw a1, a0, 31
363 ; RV64I-NEXT: srliw a1, a1, 29
364 ; RV64I-NEXT: add a0, a0, a1
365 ; RV64I-NEXT: sraiw a0, a0, 3
368 ; RV64IM-LABEL: sdiv_pow2:
370 ; RV64IM-NEXT: sraiw a1, a0, 31
371 ; RV64IM-NEXT: srliw a1, a1, 29
372 ; RV64IM-NEXT: add a0, a0, a1
373 ; RV64IM-NEXT: sraiw a0, a0, 3
379 define i32 @sdiv_pow2_2(i32 %a) nounwind {
380 ; RV64I-LABEL: sdiv_pow2_2:
382 ; RV64I-NEXT: sraiw a1, a0, 31
383 ; RV64I-NEXT: srliw a1, a1, 16
384 ; RV64I-NEXT: add a0, a0, a1
385 ; RV64I-NEXT: sraiw a0, a0, 16
388 ; RV64IM-LABEL: sdiv_pow2_2:
390 ; RV64IM-NEXT: sraiw a1, a0, 31
391 ; RV64IM-NEXT: srliw a1, a1, 16
392 ; RV64IM-NEXT: add a0, a0, a1
393 ; RV64IM-NEXT: sraiw a0, a0, 16
395 %1 = sdiv i32 %a, 65536
399 define i32 @sdiv_constant_lhs(i32 %a) nounwind {
400 ; RV64I-LABEL: sdiv_constant_lhs:
402 ; RV64I-NEXT: addi sp, sp, -16
403 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
404 ; RV64I-NEXT: sext.w a1, a0
405 ; RV64I-NEXT: li a0, -10
406 ; RV64I-NEXT: call __divdi3
407 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
408 ; RV64I-NEXT: addi sp, sp, 16
411 ; RV64IM-LABEL: sdiv_constant_lhs:
413 ; RV64IM-NEXT: li a1, -10
414 ; RV64IM-NEXT: divw a0, a1, a0
416 %1 = sdiv i32 -10, %a
420 define i64 @sdiv64(i64 %a, i64 %b) nounwind {
421 ; RV64I-LABEL: sdiv64:
423 ; RV64I-NEXT: tail __divdi3
425 ; RV64IM-LABEL: sdiv64:
427 ; RV64IM-NEXT: div a0, a0, a1
433 define i64 @sdiv64_constant(i64 %a) nounwind {
434 ; RV64I-LABEL: sdiv64_constant:
436 ; RV64I-NEXT: li a1, 5
437 ; RV64I-NEXT: tail __divdi3
439 ; RV64IM-LABEL: sdiv64_constant:
441 ; RV64IM-NEXT: lui a1, %hi(.LCPI21_0)
442 ; RV64IM-NEXT: ld a1, %lo(.LCPI21_0)(a1)
443 ; RV64IM-NEXT: mulh a0, a0, a1
444 ; RV64IM-NEXT: srli a1, a0, 63
445 ; RV64IM-NEXT: srai a0, a0, 1
446 ; RV64IM-NEXT: add a0, a0, a1
452 define i64 @sdiv64_constant_lhs(i64 %a) nounwind {
453 ; RV64I-LABEL: sdiv64_constant_lhs:
455 ; RV64I-NEXT: mv a1, a0
456 ; RV64I-NEXT: li a0, 10
457 ; RV64I-NEXT: tail __divdi3
459 ; RV64IM-LABEL: sdiv64_constant_lhs:
461 ; RV64IM-NEXT: li a1, 10
462 ; RV64IM-NEXT: div a0, a1, a0
468 ; Although this sdiv has two sexti32 operands, it shouldn't compile to divw on
469 ; RV64M as that wouldn't produce the correct result for e.g. INT_MIN/-1.
471 define i64 @sdiv64_sext_operands(i32 %a, i32 %b) nounwind {
472 ; RV64I-LABEL: sdiv64_sext_operands:
474 ; RV64I-NEXT: sext.w a0, a0
475 ; RV64I-NEXT: sext.w a1, a1
476 ; RV64I-NEXT: tail __divdi3
478 ; RV64IM-LABEL: sdiv64_sext_operands:
480 ; RV64IM-NEXT: sext.w a0, a0
481 ; RV64IM-NEXT: sext.w a1, a1
482 ; RV64IM-NEXT: div a0, a0, a1
484 %1 = sext i32 %a to i64
485 %2 = sext i32 %b to i64
490 define i8 @sdiv8(i8 %a, i8 %b) nounwind {
491 ; RV64I-LABEL: sdiv8:
493 ; RV64I-NEXT: addi sp, sp, -16
494 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
495 ; RV64I-NEXT: slli a1, a1, 24
496 ; RV64I-NEXT: sraiw a1, a1, 24
497 ; RV64I-NEXT: slli a0, a0, 24
498 ; RV64I-NEXT: sraiw a0, a0, 24
499 ; RV64I-NEXT: call __divdi3
500 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
501 ; RV64I-NEXT: addi sp, sp, 16
504 ; RV64IM-LABEL: sdiv8:
506 ; RV64IM-NEXT: slli a1, a1, 24
507 ; RV64IM-NEXT: sraiw a1, a1, 24
508 ; RV64IM-NEXT: slli a0, a0, 24
509 ; RV64IM-NEXT: sraiw a0, a0, 24
510 ; RV64IM-NEXT: divw a0, a0, a1
516 define i8 @sdiv8_constant(i8 %a) nounwind {
517 ; RV64I-LABEL: sdiv8_constant:
519 ; RV64I-NEXT: addi sp, sp, -16
520 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
521 ; RV64I-NEXT: slli a0, a0, 24
522 ; RV64I-NEXT: sraiw a0, a0, 24
523 ; RV64I-NEXT: li a1, 5
524 ; RV64I-NEXT: call __divdi3
525 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
526 ; RV64I-NEXT: addi sp, sp, 16
529 ; RV64IM-LABEL: sdiv8_constant:
531 ; RV64IM-NEXT: slli a0, a0, 24
532 ; RV64IM-NEXT: sraiw a0, a0, 24
533 ; RV64IM-NEXT: li a1, 103
534 ; RV64IM-NEXT: mul a0, a0, a1
535 ; RV64IM-NEXT: sraiw a1, a0, 9
536 ; RV64IM-NEXT: slli a0, a0, 48
537 ; RV64IM-NEXT: srli a0, a0, 63
538 ; RV64IM-NEXT: addw a0, a1, a0
544 define i8 @sdiv8_pow2(i8 %a) nounwind {
545 ; RV64I-LABEL: sdiv8_pow2:
547 ; RV64I-NEXT: slli a1, a0, 24
548 ; RV64I-NEXT: sraiw a1, a1, 24
549 ; RV64I-NEXT: slli a1, a1, 49
550 ; RV64I-NEXT: srli a1, a1, 61
551 ; RV64I-NEXT: add a0, a0, a1
552 ; RV64I-NEXT: slli a0, a0, 24
553 ; RV64I-NEXT: sraiw a0, a0, 27
556 ; RV64IM-LABEL: sdiv8_pow2:
558 ; RV64IM-NEXT: slli a1, a0, 24
559 ; RV64IM-NEXT: sraiw a1, a1, 24
560 ; RV64IM-NEXT: slli a1, a1, 49
561 ; RV64IM-NEXT: srli a1, a1, 61
562 ; RV64IM-NEXT: add a0, a0, a1
563 ; RV64IM-NEXT: slli a0, a0, 24
564 ; RV64IM-NEXT: sraiw a0, a0, 27
570 define i8 @sdiv8_constant_lhs(i8 %a) nounwind {
571 ; RV64I-LABEL: sdiv8_constant_lhs:
573 ; RV64I-NEXT: addi sp, sp, -16
574 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
575 ; RV64I-NEXT: slli a0, a0, 24
576 ; RV64I-NEXT: sraiw a1, a0, 24
577 ; RV64I-NEXT: li a0, -10
578 ; RV64I-NEXT: call __divdi3
579 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
580 ; RV64I-NEXT: addi sp, sp, 16
583 ; RV64IM-LABEL: sdiv8_constant_lhs:
585 ; RV64IM-NEXT: slli a0, a0, 24
586 ; RV64IM-NEXT: sraiw a0, a0, 24
587 ; RV64IM-NEXT: li a1, -10
588 ; RV64IM-NEXT: divw a0, a1, a0
594 define i16 @sdiv16(i16 %a, i16 %b) nounwind {
595 ; RV64I-LABEL: sdiv16:
597 ; RV64I-NEXT: addi sp, sp, -16
598 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
599 ; RV64I-NEXT: slli a1, a1, 16
600 ; RV64I-NEXT: sraiw a1, a1, 16
601 ; RV64I-NEXT: slli a0, a0, 16
602 ; RV64I-NEXT: sraiw a0, a0, 16
603 ; RV64I-NEXT: call __divdi3
604 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
605 ; RV64I-NEXT: addi sp, sp, 16
608 ; RV64IM-LABEL: sdiv16:
610 ; RV64IM-NEXT: slli a1, a1, 16
611 ; RV64IM-NEXT: sraiw a1, a1, 16
612 ; RV64IM-NEXT: slli a0, a0, 16
613 ; RV64IM-NEXT: sraiw a0, a0, 16
614 ; RV64IM-NEXT: divw a0, a0, a1
620 define i16 @sdiv16_constant(i16 %a) nounwind {
621 ; RV64I-LABEL: sdiv16_constant:
623 ; RV64I-NEXT: addi sp, sp, -16
624 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
625 ; RV64I-NEXT: slli a0, a0, 16
626 ; RV64I-NEXT: sraiw a0, a0, 16
627 ; RV64I-NEXT: li a1, 5
628 ; RV64I-NEXT: call __divdi3
629 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
630 ; RV64I-NEXT: addi sp, sp, 16
633 ; RV64IM-LABEL: sdiv16_constant:
635 ; RV64IM-NEXT: slli a0, a0, 16
636 ; RV64IM-NEXT: sraiw a0, a0, 16
637 ; RV64IM-NEXT: lui a1, 6
638 ; RV64IM-NEXT: addi a1, a1, 1639
639 ; RV64IM-NEXT: mul a0, a0, a1
640 ; RV64IM-NEXT: srliw a1, a0, 31
641 ; RV64IM-NEXT: sraiw a0, a0, 17
642 ; RV64IM-NEXT: addw a0, a0, a1
648 define i16 @sdiv16_pow2(i16 %a) nounwind {
649 ; RV64I-LABEL: sdiv16_pow2:
651 ; RV64I-NEXT: slli a1, a0, 16
652 ; RV64I-NEXT: sraiw a1, a1, 16
653 ; RV64I-NEXT: slli a1, a1, 33
654 ; RV64I-NEXT: srli a1, a1, 61
655 ; RV64I-NEXT: add a0, a0, a1
656 ; RV64I-NEXT: slli a0, a0, 16
657 ; RV64I-NEXT: sraiw a0, a0, 19
660 ; RV64IM-LABEL: sdiv16_pow2:
662 ; RV64IM-NEXT: slli a1, a0, 16
663 ; RV64IM-NEXT: sraiw a1, a1, 16
664 ; RV64IM-NEXT: slli a1, a1, 33
665 ; RV64IM-NEXT: srli a1, a1, 61
666 ; RV64IM-NEXT: add a0, a0, a1
667 ; RV64IM-NEXT: slli a0, a0, 16
668 ; RV64IM-NEXT: sraiw a0, a0, 19
674 define i16 @sdiv16_constant_lhs(i16 %a) nounwind {
675 ; RV64I-LABEL: sdiv16_constant_lhs:
677 ; RV64I-NEXT: addi sp, sp, -16
678 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
679 ; RV64I-NEXT: slli a0, a0, 16
680 ; RV64I-NEXT: sraiw a1, a0, 16
681 ; RV64I-NEXT: li a0, -10
682 ; RV64I-NEXT: call __divdi3
683 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
684 ; RV64I-NEXT: addi sp, sp, 16
687 ; RV64IM-LABEL: sdiv16_constant_lhs:
689 ; RV64IM-NEXT: slli a0, a0, 16
690 ; RV64IM-NEXT: sraiw a0, a0, 16
691 ; RV64IM-NEXT: li a1, -10
692 ; RV64IM-NEXT: divw a0, a1, a0
694 %1 = sdiv i16 -10, %a