1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck -check-prefix=RV32I %s
4 ; RUN: llc -mtriple=riscv32 -mattr=+m -verify-machineinstrs < %s \
5 ; RUN: | FileCheck -check-prefix=RV32IM %s
6 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
7 ; RUN: | FileCheck -check-prefix=RV64I %s
8 ; RUN: llc -mtriple=riscv64 -mattr=+m -verify-machineinstrs < %s \
9 ; RUN: | FileCheck -check-prefix=RV64IM %s
11 define signext i32 @square(i32 %a) nounwind {
12 ; RV32I-LABEL: square:
14 ; RV32I-NEXT: addi sp, sp, -16
15 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
16 ; RV32I-NEXT: mv a1, a0
17 ; RV32I-NEXT: call __mulsi3@plt
18 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
19 ; RV32I-NEXT: addi sp, sp, 16
22 ; RV32IM-LABEL: square:
24 ; RV32IM-NEXT: mul a0, a0, a0
27 ; RV64I-LABEL: square:
29 ; RV64I-NEXT: addi sp, sp, -16
30 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
31 ; RV64I-NEXT: mv a1, a0
32 ; RV64I-NEXT: call __muldi3@plt
33 ; RV64I-NEXT: sext.w a0, a0
34 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
35 ; RV64I-NEXT: addi sp, sp, 16
38 ; RV64IM-LABEL: square:
40 ; RV64IM-NEXT: mulw a0, a0, a0
46 define signext i32 @mul(i32 %a, i32 %b) nounwind {
49 ; RV32I-NEXT: addi sp, sp, -16
50 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
51 ; RV32I-NEXT: call __mulsi3@plt
52 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
53 ; RV32I-NEXT: addi sp, sp, 16
58 ; RV32IM-NEXT: mul a0, a0, a1
63 ; RV64I-NEXT: addi sp, sp, -16
64 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
65 ; RV64I-NEXT: call __muldi3@plt
66 ; RV64I-NEXT: sext.w a0, a0
67 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
68 ; RV64I-NEXT: addi sp, sp, 16
73 ; RV64IM-NEXT: mulw a0, a0, a1
79 define signext i32 @mul_constant(i32 %a) nounwind {
80 ; RV32I-LABEL: mul_constant:
82 ; RV32I-NEXT: slli a1, a0, 2
83 ; RV32I-NEXT: add a0, a1, a0
86 ; RV32IM-LABEL: mul_constant:
88 ; RV32IM-NEXT: slli a1, a0, 2
89 ; RV32IM-NEXT: add a0, a1, a0
92 ; RV64I-LABEL: mul_constant:
94 ; RV64I-NEXT: slli a1, a0, 2
95 ; RV64I-NEXT: addw a0, a1, a0
98 ; RV64IM-LABEL: mul_constant:
100 ; RV64IM-NEXT: slli a1, a0, 2
101 ; RV64IM-NEXT: addw a0, a1, a0
107 define i32 @mul_pow2(i32 %a) nounwind {
108 ; RV32I-LABEL: mul_pow2:
110 ; RV32I-NEXT: slli a0, a0, 3
113 ; RV32IM-LABEL: mul_pow2:
115 ; RV32IM-NEXT: slli a0, a0, 3
118 ; RV64I-LABEL: mul_pow2:
120 ; RV64I-NEXT: slliw a0, a0, 3
123 ; RV64IM-LABEL: mul_pow2:
125 ; RV64IM-NEXT: slliw a0, a0, 3
131 define i64 @mul64(i64 %a, i64 %b) nounwind {
132 ; RV32I-LABEL: mul64:
134 ; RV32I-NEXT: addi sp, sp, -16
135 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
136 ; RV32I-NEXT: call __muldi3@plt
137 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
138 ; RV32I-NEXT: addi sp, sp, 16
141 ; RV32IM-LABEL: mul64:
143 ; RV32IM-NEXT: mul a3, a0, a3
144 ; RV32IM-NEXT: mulhu a4, a0, a2
145 ; RV32IM-NEXT: add a3, a4, a3
146 ; RV32IM-NEXT: mul a1, a1, a2
147 ; RV32IM-NEXT: add a1, a3, a1
148 ; RV32IM-NEXT: mul a0, a0, a2
151 ; RV64I-LABEL: mul64:
153 ; RV64I-NEXT: tail __muldi3@plt
155 ; RV64IM-LABEL: mul64:
157 ; RV64IM-NEXT: mul a0, a0, a1
163 define i64 @mul64_constant(i64 %a) nounwind {
164 ; RV32I-LABEL: mul64_constant:
166 ; RV32I-NEXT: slli a3, a0, 2
167 ; RV32I-NEXT: add a2, a3, a0
168 ; RV32I-NEXT: sltu a3, a2, a3
169 ; RV32I-NEXT: srli a0, a0, 30
170 ; RV32I-NEXT: slli a4, a1, 2
171 ; RV32I-NEXT: or a0, a4, a0
172 ; RV32I-NEXT: add a0, a0, a1
173 ; RV32I-NEXT: add a1, a0, a3
174 ; RV32I-NEXT: mv a0, a2
177 ; RV32IM-LABEL: mul64_constant:
179 ; RV32IM-NEXT: li a2, 5
180 ; RV32IM-NEXT: mulhu a2, a0, a2
181 ; RV32IM-NEXT: slli a3, a1, 2
182 ; RV32IM-NEXT: add a1, a3, a1
183 ; RV32IM-NEXT: add a1, a2, a1
184 ; RV32IM-NEXT: slli a2, a0, 2
185 ; RV32IM-NEXT: add a0, a2, a0
188 ; RV64I-LABEL: mul64_constant:
190 ; RV64I-NEXT: slli a1, a0, 2
191 ; RV64I-NEXT: add a0, a1, a0
194 ; RV64IM-LABEL: mul64_constant:
196 ; RV64IM-NEXT: slli a1, a0, 2
197 ; RV64IM-NEXT: add a0, a1, a0
203 define i32 @mulhs(i32 %a, i32 %b) nounwind {
204 ; RV32I-LABEL: mulhs:
206 ; RV32I-NEXT: addi sp, sp, -16
207 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
208 ; RV32I-NEXT: mv a2, a1
209 ; RV32I-NEXT: srai a1, a0, 31
210 ; RV32I-NEXT: srai a3, a2, 31
211 ; RV32I-NEXT: call __muldi3@plt
212 ; RV32I-NEXT: mv a0, a1
213 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
214 ; RV32I-NEXT: addi sp, sp, 16
217 ; RV32IM-LABEL: mulhs:
219 ; RV32IM-NEXT: mulh a0, a0, a1
222 ; RV64I-LABEL: mulhs:
224 ; RV64I-NEXT: addi sp, sp, -16
225 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
226 ; RV64I-NEXT: sext.w a0, a0
227 ; RV64I-NEXT: sext.w a1, a1
228 ; RV64I-NEXT: call __muldi3@plt
229 ; RV64I-NEXT: srli a0, a0, 32
230 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
231 ; RV64I-NEXT: addi sp, sp, 16
234 ; RV64IM-LABEL: mulhs:
236 ; RV64IM-NEXT: sext.w a0, a0
237 ; RV64IM-NEXT: sext.w a1, a1
238 ; RV64IM-NEXT: mul a0, a0, a1
239 ; RV64IM-NEXT: srli a0, a0, 32
241 %1 = sext i32 %a to i64
242 %2 = sext i32 %b to i64
245 %5 = trunc i64 %4 to i32
249 define i32 @mulhs_positive_constant(i32 %a) nounwind {
250 ; RV32I-LABEL: mulhs_positive_constant:
252 ; RV32I-NEXT: srai a1, a0, 31
253 ; RV32I-NEXT: slli a2, a0, 2
254 ; RV32I-NEXT: add a3, a2, a0
255 ; RV32I-NEXT: sltu a2, a3, a2
256 ; RV32I-NEXT: srli a0, a0, 30
257 ; RV32I-NEXT: slli a3, a1, 2
258 ; RV32I-NEXT: or a0, a3, a0
259 ; RV32I-NEXT: add a0, a0, a1
260 ; RV32I-NEXT: add a0, a0, a2
263 ; RV32IM-LABEL: mulhs_positive_constant:
265 ; RV32IM-NEXT: li a1, 5
266 ; RV32IM-NEXT: mulh a0, a0, a1
269 ; RV64I-LABEL: mulhs_positive_constant:
271 ; RV64I-NEXT: sext.w a0, a0
272 ; RV64I-NEXT: slli a1, a0, 2
273 ; RV64I-NEXT: add a0, a1, a0
274 ; RV64I-NEXT: srli a0, a0, 32
277 ; RV64IM-LABEL: mulhs_positive_constant:
279 ; RV64IM-NEXT: sext.w a0, a0
280 ; RV64IM-NEXT: slli a1, a0, 2
281 ; RV64IM-NEXT: add a0, a1, a0
282 ; RV64IM-NEXT: srli a0, a0, 32
284 %1 = sext i32 %a to i64
287 %4 = trunc i64 %3 to i32
291 define i32 @mulhs_negative_constant(i32 %a) nounwind {
292 ; RV32I-LABEL: mulhs_negative_constant:
294 ; RV32I-NEXT: srai a1, a0, 31
295 ; RV32I-NEXT: slli a2, a0, 2
296 ; RV32I-NEXT: add a3, a2, a0
297 ; RV32I-NEXT: sltu a2, a3, a2
298 ; RV32I-NEXT: srli a0, a0, 30
299 ; RV32I-NEXT: slli a4, a1, 2
300 ; RV32I-NEXT: or a0, a4, a0
301 ; RV32I-NEXT: add a0, a0, a1
302 ; RV32I-NEXT: snez a1, a3
303 ; RV32I-NEXT: add a1, a2, a1
304 ; RV32I-NEXT: add a0, a0, a1
305 ; RV32I-NEXT: neg a0, a0
308 ; RV32IM-LABEL: mulhs_negative_constant:
310 ; RV32IM-NEXT: li a1, -5
311 ; RV32IM-NEXT: mulh a0, a0, a1
314 ; RV64I-LABEL: mulhs_negative_constant:
316 ; RV64I-NEXT: sext.w a0, a0
317 ; RV64I-NEXT: slli a1, a0, 2
318 ; RV64I-NEXT: neg a0, a0
319 ; RV64I-NEXT: sub a0, a0, a1
320 ; RV64I-NEXT: srli a0, a0, 32
323 ; RV64IM-LABEL: mulhs_negative_constant:
325 ; RV64IM-NEXT: sext.w a0, a0
326 ; RV64IM-NEXT: slli a1, a0, 2
327 ; RV64IM-NEXT: neg a0, a0
328 ; RV64IM-NEXT: sub a0, a0, a1
329 ; RV64IM-NEXT: srli a0, a0, 32
331 %1 = sext i32 %a to i64
334 %4 = trunc i64 %3 to i32
338 define zeroext i32 @mulhu(i32 zeroext %a, i32 zeroext %b) nounwind {
339 ; RV32I-LABEL: mulhu:
341 ; RV32I-NEXT: addi sp, sp, -16
342 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
343 ; RV32I-NEXT: mv a2, a1
344 ; RV32I-NEXT: li a1, 0
345 ; RV32I-NEXT: li a3, 0
346 ; RV32I-NEXT: call __muldi3@plt
347 ; RV32I-NEXT: mv a0, a1
348 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
349 ; RV32I-NEXT: addi sp, sp, 16
352 ; RV32IM-LABEL: mulhu:
354 ; RV32IM-NEXT: mulhu a0, a0, a1
357 ; RV64I-LABEL: mulhu:
359 ; RV64I-NEXT: addi sp, sp, -16
360 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
361 ; RV64I-NEXT: call __muldi3@plt
362 ; RV64I-NEXT: srli a0, a0, 32
363 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
364 ; RV64I-NEXT: addi sp, sp, 16
367 ; RV64IM-LABEL: mulhu:
369 ; RV64IM-NEXT: mul a0, a0, a1
370 ; RV64IM-NEXT: srli a0, a0, 32
372 %1 = zext i32 %a to i64
373 %2 = zext i32 %b to i64
376 %5 = trunc i64 %4 to i32
380 define i32 @mulhsu(i32 %a, i32 %b) nounwind {
381 ; RV32I-LABEL: mulhsu:
383 ; RV32I-NEXT: addi sp, sp, -16
384 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
385 ; RV32I-NEXT: mv a2, a1
386 ; RV32I-NEXT: srai a3, a1, 31
387 ; RV32I-NEXT: li a1, 0
388 ; RV32I-NEXT: call __muldi3@plt
389 ; RV32I-NEXT: mv a0, a1
390 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
391 ; RV32I-NEXT: addi sp, sp, 16
394 ; RV32IM-LABEL: mulhsu:
396 ; RV32IM-NEXT: mulhsu a0, a1, a0
399 ; RV64I-LABEL: mulhsu:
401 ; RV64I-NEXT: addi sp, sp, -16
402 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
403 ; RV64I-NEXT: slli a0, a0, 32
404 ; RV64I-NEXT: srli a0, a0, 32
405 ; RV64I-NEXT: sext.w a1, a1
406 ; RV64I-NEXT: call __muldi3@plt
407 ; RV64I-NEXT: srli a0, a0, 32
408 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
409 ; RV64I-NEXT: addi sp, sp, 16
412 ; RV64IM-LABEL: mulhsu:
414 ; RV64IM-NEXT: slli a0, a0, 32
415 ; RV64IM-NEXT: srli a0, a0, 32
416 ; RV64IM-NEXT: sext.w a1, a1
417 ; RV64IM-NEXT: mul a0, a0, a1
418 ; RV64IM-NEXT: srli a0, a0, 32
420 %1 = zext i32 %a to i64
421 %2 = sext i32 %b to i64
424 %5 = trunc i64 %4 to i32
428 define i32 @mulhu_constant(i32 %a) nounwind {
429 ; RV32I-LABEL: mulhu_constant:
431 ; RV32I-NEXT: slli a1, a0, 2
432 ; RV32I-NEXT: add a2, a1, a0
433 ; RV32I-NEXT: sltu a1, a2, a1
434 ; RV32I-NEXT: srli a0, a0, 30
435 ; RV32I-NEXT: add a0, a0, a1
438 ; RV32IM-LABEL: mulhu_constant:
440 ; RV32IM-NEXT: li a1, 5
441 ; RV32IM-NEXT: mulhu a0, a0, a1
444 ; RV64I-LABEL: mulhu_constant:
446 ; RV64I-NEXT: slli a0, a0, 32
447 ; RV64I-NEXT: srli a1, a0, 32
448 ; RV64I-NEXT: srli a0, a0, 30
449 ; RV64I-NEXT: add a0, a0, a1
450 ; RV64I-NEXT: srli a0, a0, 32
453 ; RV64IM-LABEL: mulhu_constant:
455 ; RV64IM-NEXT: slli a0, a0, 32
456 ; RV64IM-NEXT: srli a1, a0, 32
457 ; RV64IM-NEXT: srli a0, a0, 30
458 ; RV64IM-NEXT: add a0, a0, a1
459 ; RV64IM-NEXT: srli a0, a0, 32
461 %1 = zext i32 %a to i64
464 %4 = trunc i64 %3 to i32
468 define i32 @muli32_p65(i32 %a) nounwind {
469 ; RV32I-LABEL: muli32_p65:
471 ; RV32I-NEXT: slli a1, a0, 6
472 ; RV32I-NEXT: add a0, a1, a0
475 ; RV32IM-LABEL: muli32_p65:
477 ; RV32IM-NEXT: slli a1, a0, 6
478 ; RV32IM-NEXT: add a0, a1, a0
481 ; RV64I-LABEL: muli32_p65:
483 ; RV64I-NEXT: slli a1, a0, 6
484 ; RV64I-NEXT: addw a0, a1, a0
487 ; RV64IM-LABEL: muli32_p65:
489 ; RV64IM-NEXT: slli a1, a0, 6
490 ; RV64IM-NEXT: addw a0, a1, a0
496 define i32 @muli32_p63(i32 %a) nounwind {
497 ; RV32I-LABEL: muli32_p63:
499 ; RV32I-NEXT: slli a1, a0, 6
500 ; RV32I-NEXT: sub a0, a1, a0
503 ; RV32IM-LABEL: muli32_p63:
505 ; RV32IM-NEXT: slli a1, a0, 6
506 ; RV32IM-NEXT: sub a0, a1, a0
509 ; RV64I-LABEL: muli32_p63:
511 ; RV64I-NEXT: slli a1, a0, 6
512 ; RV64I-NEXT: subw a0, a1, a0
515 ; RV64IM-LABEL: muli32_p63:
517 ; RV64IM-NEXT: slli a1, a0, 6
518 ; RV64IM-NEXT: subw a0, a1, a0
524 define i64 @muli64_p65(i64 %a) nounwind {
525 ; RV32I-LABEL: muli64_p65:
527 ; RV32I-NEXT: slli a3, a0, 6
528 ; RV32I-NEXT: add a2, a3, a0
529 ; RV32I-NEXT: sltu a3, a2, a3
530 ; RV32I-NEXT: srli a0, a0, 26
531 ; RV32I-NEXT: slli a4, a1, 6
532 ; RV32I-NEXT: or a0, a4, a0
533 ; RV32I-NEXT: add a0, a0, a1
534 ; RV32I-NEXT: add a1, a0, a3
535 ; RV32I-NEXT: mv a0, a2
538 ; RV32IM-LABEL: muli64_p65:
540 ; RV32IM-NEXT: li a2, 65
541 ; RV32IM-NEXT: mulhu a2, a0, a2
542 ; RV32IM-NEXT: slli a3, a1, 6
543 ; RV32IM-NEXT: add a1, a3, a1
544 ; RV32IM-NEXT: add a1, a2, a1
545 ; RV32IM-NEXT: slli a2, a0, 6
546 ; RV32IM-NEXT: add a0, a2, a0
549 ; RV64I-LABEL: muli64_p65:
551 ; RV64I-NEXT: slli a1, a0, 6
552 ; RV64I-NEXT: add a0, a1, a0
555 ; RV64IM-LABEL: muli64_p65:
557 ; RV64IM-NEXT: slli a1, a0, 6
558 ; RV64IM-NEXT: add a0, a1, a0
564 define i64 @muli64_p63(i64 %a) nounwind {
565 ; RV32I-LABEL: muli64_p63:
567 ; RV32I-NEXT: slli a2, a0, 6
568 ; RV32I-NEXT: sltu a3, a2, a0
569 ; RV32I-NEXT: srli a4, a0, 26
570 ; RV32I-NEXT: slli a5, a1, 6
571 ; RV32I-NEXT: or a4, a5, a4
572 ; RV32I-NEXT: sub a1, a4, a1
573 ; RV32I-NEXT: sub a1, a1, a3
574 ; RV32I-NEXT: sub a0, a2, a0
577 ; RV32IM-LABEL: muli64_p63:
579 ; RV32IM-NEXT: li a2, 63
580 ; RV32IM-NEXT: mulhu a2, a0, a2
581 ; RV32IM-NEXT: slli a3, a1, 6
582 ; RV32IM-NEXT: sub a1, a3, a1
583 ; RV32IM-NEXT: add a1, a2, a1
584 ; RV32IM-NEXT: slli a2, a0, 6
585 ; RV32IM-NEXT: sub a0, a2, a0
588 ; RV64I-LABEL: muli64_p63:
590 ; RV64I-NEXT: slli a1, a0, 6
591 ; RV64I-NEXT: sub a0, a1, a0
594 ; RV64IM-LABEL: muli64_p63:
596 ; RV64IM-NEXT: slli a1, a0, 6
597 ; RV64IM-NEXT: sub a0, a1, a0
603 define i32 @muli32_m63(i32 %a) nounwind {
604 ; RV32I-LABEL: muli32_m63:
606 ; RV32I-NEXT: slli a1, a0, 6
607 ; RV32I-NEXT: sub a0, a0, a1
610 ; RV32IM-LABEL: muli32_m63:
612 ; RV32IM-NEXT: slli a1, a0, 6
613 ; RV32IM-NEXT: sub a0, a0, a1
616 ; RV64I-LABEL: muli32_m63:
618 ; RV64I-NEXT: slli a1, a0, 6
619 ; RV64I-NEXT: subw a0, a0, a1
622 ; RV64IM-LABEL: muli32_m63:
624 ; RV64IM-NEXT: slli a1, a0, 6
625 ; RV64IM-NEXT: subw a0, a0, a1
631 define i32 @muli32_m65(i32 %a) nounwind {
632 ; RV32I-LABEL: muli32_m65:
634 ; RV32I-NEXT: slli a1, a0, 6
635 ; RV32I-NEXT: neg a0, a0
636 ; RV32I-NEXT: sub a0, a0, a1
639 ; RV32IM-LABEL: muli32_m65:
641 ; RV32IM-NEXT: slli a1, a0, 6
642 ; RV32IM-NEXT: neg a0, a0
643 ; RV32IM-NEXT: sub a0, a0, a1
646 ; RV64I-LABEL: muli32_m65:
648 ; RV64I-NEXT: slli a1, a0, 6
649 ; RV64I-NEXT: negw a0, a0
650 ; RV64I-NEXT: subw a0, a0, a1
653 ; RV64IM-LABEL: muli32_m65:
655 ; RV64IM-NEXT: slli a1, a0, 6
656 ; RV64IM-NEXT: negw a0, a0
657 ; RV64IM-NEXT: subw a0, a0, a1
663 define i64 @muli64_m63(i64 %a) nounwind {
664 ; RV32I-LABEL: muli64_m63:
666 ; RV32I-NEXT: slli a2, a0, 6
667 ; RV32I-NEXT: sltu a3, a0, a2
668 ; RV32I-NEXT: srli a4, a0, 26
669 ; RV32I-NEXT: slli a5, a1, 6
670 ; RV32I-NEXT: or a4, a5, a4
671 ; RV32I-NEXT: sub a1, a1, a4
672 ; RV32I-NEXT: sub a1, a1, a3
673 ; RV32I-NEXT: sub a0, a0, a2
676 ; RV32IM-LABEL: muli64_m63:
678 ; RV32IM-NEXT: slli a2, a1, 6
679 ; RV32IM-NEXT: sub a1, a1, a2
680 ; RV32IM-NEXT: li a2, -63
681 ; RV32IM-NEXT: mulhu a2, a0, a2
682 ; RV32IM-NEXT: sub a2, a2, a0
683 ; RV32IM-NEXT: add a1, a2, a1
684 ; RV32IM-NEXT: slli a2, a0, 6
685 ; RV32IM-NEXT: sub a0, a0, a2
688 ; RV64I-LABEL: muli64_m63:
690 ; RV64I-NEXT: slli a1, a0, 6
691 ; RV64I-NEXT: sub a0, a0, a1
694 ; RV64IM-LABEL: muli64_m63:
696 ; RV64IM-NEXT: slli a1, a0, 6
697 ; RV64IM-NEXT: sub a0, a0, a1
703 define i64 @muli64_m65(i64 %a) nounwind {
704 ; RV32I-LABEL: muli64_m65:
706 ; RV32I-NEXT: slli a2, a0, 6
707 ; RV32I-NEXT: add a3, a2, a0
708 ; RV32I-NEXT: sltu a2, a3, a2
709 ; RV32I-NEXT: srli a0, a0, 26
710 ; RV32I-NEXT: slli a4, a1, 6
711 ; RV32I-NEXT: or a0, a4, a0
712 ; RV32I-NEXT: add a0, a0, a1
713 ; RV32I-NEXT: add a0, a0, a2
714 ; RV32I-NEXT: snez a1, a3
715 ; RV32I-NEXT: neg a1, a1
716 ; RV32I-NEXT: sub a1, a1, a0
717 ; RV32I-NEXT: neg a0, a3
720 ; RV32IM-LABEL: muli64_m65:
722 ; RV32IM-NEXT: slli a2, a1, 6
723 ; RV32IM-NEXT: add a1, a2, a1
724 ; RV32IM-NEXT: li a2, -65
725 ; RV32IM-NEXT: mulhu a2, a0, a2
726 ; RV32IM-NEXT: sub a2, a2, a0
727 ; RV32IM-NEXT: sub a1, a2, a1
728 ; RV32IM-NEXT: slli a2, a0, 6
729 ; RV32IM-NEXT: neg a0, a0
730 ; RV32IM-NEXT: sub a0, a0, a2
733 ; RV64I-LABEL: muli64_m65:
735 ; RV64I-NEXT: slli a1, a0, 6
736 ; RV64I-NEXT: neg a0, a0
737 ; RV64I-NEXT: sub a0, a0, a1
740 ; RV64IM-LABEL: muli64_m65:
742 ; RV64IM-NEXT: slli a1, a0, 6
743 ; RV64IM-NEXT: neg a0, a0
744 ; RV64IM-NEXT: sub a0, a0, a1
750 define i32 @muli32_p384(i32 %a) nounwind {
751 ; RV32I-LABEL: muli32_p384:
753 ; RV32I-NEXT: li a1, 384
754 ; RV32I-NEXT: tail __mulsi3@plt
756 ; RV32IM-LABEL: muli32_p384:
758 ; RV32IM-NEXT: li a1, 384
759 ; RV32IM-NEXT: mul a0, a0, a1
762 ; RV64I-LABEL: muli32_p384:
764 ; RV64I-NEXT: addi sp, sp, -16
765 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
766 ; RV64I-NEXT: li a1, 384
767 ; RV64I-NEXT: call __muldi3@plt
768 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
769 ; RV64I-NEXT: addi sp, sp, 16
772 ; RV64IM-LABEL: muli32_p384:
774 ; RV64IM-NEXT: li a1, 384
775 ; RV64IM-NEXT: mulw a0, a0, a1
781 define i32 @muli32_p12288(i32 %a) nounwind {
782 ; RV32I-LABEL: muli32_p12288:
784 ; RV32I-NEXT: lui a1, 3
785 ; RV32I-NEXT: tail __mulsi3@plt
787 ; RV32IM-LABEL: muli32_p12288:
789 ; RV32IM-NEXT: lui a1, 3
790 ; RV32IM-NEXT: mul a0, a0, a1
793 ; RV64I-LABEL: muli32_p12288:
795 ; RV64I-NEXT: addi sp, sp, -16
796 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
797 ; RV64I-NEXT: lui a1, 3
798 ; RV64I-NEXT: call __muldi3@plt
799 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
800 ; RV64I-NEXT: addi sp, sp, 16
803 ; RV64IM-LABEL: muli32_p12288:
805 ; RV64IM-NEXT: lui a1, 3
806 ; RV64IM-NEXT: mulw a0, a0, a1
808 %1 = mul i32 %a, 12288
812 define i32 @muli32_p4352(i32 %a) nounwind {
813 ; RV32I-LABEL: muli32_p4352:
815 ; RV32I-NEXT: slli a1, a0, 8
816 ; RV32I-NEXT: slli a0, a0, 12
817 ; RV32I-NEXT: add a0, a0, a1
820 ; RV32IM-LABEL: muli32_p4352:
822 ; RV32IM-NEXT: slli a1, a0, 8
823 ; RV32IM-NEXT: slli a0, a0, 12
824 ; RV32IM-NEXT: add a0, a0, a1
827 ; RV64I-LABEL: muli32_p4352:
829 ; RV64I-NEXT: slli a1, a0, 8
830 ; RV64I-NEXT: slli a0, a0, 12
831 ; RV64I-NEXT: addw a0, a0, a1
834 ; RV64IM-LABEL: muli32_p4352:
836 ; RV64IM-NEXT: slli a1, a0, 8
837 ; RV64IM-NEXT: slli a0, a0, 12
838 ; RV64IM-NEXT: addw a0, a0, a1
840 %1 = mul i32 %a, 4352
844 define i32 @muli32_p3840(i32 %a) nounwind {
845 ; RV32I-LABEL: muli32_p3840:
847 ; RV32I-NEXT: slli a1, a0, 8
848 ; RV32I-NEXT: slli a0, a0, 12
849 ; RV32I-NEXT: sub a0, a0, a1
852 ; RV32IM-LABEL: muli32_p3840:
854 ; RV32IM-NEXT: slli a1, a0, 8
855 ; RV32IM-NEXT: slli a0, a0, 12
856 ; RV32IM-NEXT: sub a0, a0, a1
859 ; RV64I-LABEL: muli32_p3840:
861 ; RV64I-NEXT: slli a1, a0, 8
862 ; RV64I-NEXT: slli a0, a0, 12
863 ; RV64I-NEXT: subw a0, a0, a1
866 ; RV64IM-LABEL: muli32_p3840:
868 ; RV64IM-NEXT: slli a1, a0, 8
869 ; RV64IM-NEXT: slli a0, a0, 12
870 ; RV64IM-NEXT: subw a0, a0, a1
872 %1 = mul i32 %a, 3840
876 define i32 @muli32_m3840(i32 %a) nounwind {
877 ; RV32I-LABEL: muli32_m3840:
879 ; RV32I-NEXT: slli a1, a0, 12
880 ; RV32I-NEXT: slli a0, a0, 8
881 ; RV32I-NEXT: sub a0, a0, a1
884 ; RV32IM-LABEL: muli32_m3840:
886 ; RV32IM-NEXT: slli a1, a0, 12
887 ; RV32IM-NEXT: slli a0, a0, 8
888 ; RV32IM-NEXT: sub a0, a0, a1
891 ; RV64I-LABEL: muli32_m3840:
893 ; RV64I-NEXT: slli a1, a0, 12
894 ; RV64I-NEXT: slli a0, a0, 8
895 ; RV64I-NEXT: subw a0, a0, a1
898 ; RV64IM-LABEL: muli32_m3840:
900 ; RV64IM-NEXT: slli a1, a0, 12
901 ; RV64IM-NEXT: slli a0, a0, 8
902 ; RV64IM-NEXT: subw a0, a0, a1
904 %1 = mul i32 %a, -3840
908 define i32 @muli32_m4352(i32 %a) nounwind {
909 ; RV32I-LABEL: muli32_m4352:
911 ; RV32I-NEXT: li a1, -17
912 ; RV32I-NEXT: slli a1, a1, 8
913 ; RV32I-NEXT: tail __mulsi3@plt
915 ; RV32IM-LABEL: muli32_m4352:
917 ; RV32IM-NEXT: li a1, -17
918 ; RV32IM-NEXT: slli a1, a1, 8
919 ; RV32IM-NEXT: mul a0, a0, a1
922 ; RV64I-LABEL: muli32_m4352:
924 ; RV64I-NEXT: addi sp, sp, -16
925 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
926 ; RV64I-NEXT: li a1, -17
927 ; RV64I-NEXT: slli a1, a1, 8
928 ; RV64I-NEXT: call __muldi3@plt
929 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
930 ; RV64I-NEXT: addi sp, sp, 16
933 ; RV64IM-LABEL: muli32_m4352:
935 ; RV64IM-NEXT: li a1, -17
936 ; RV64IM-NEXT: slli a1, a1, 8
937 ; RV64IM-NEXT: mulw a0, a0, a1
939 %1 = mul i32 %a, -4352
943 define i64 @muli64_p4352(i64 %a) nounwind {
944 ; RV32I-LABEL: muli64_p4352:
946 ; RV32I-NEXT: srli a2, a0, 24
947 ; RV32I-NEXT: slli a3, a1, 8
948 ; RV32I-NEXT: or a2, a3, a2
949 ; RV32I-NEXT: srli a3, a0, 20
950 ; RV32I-NEXT: slli a1, a1, 12
951 ; RV32I-NEXT: or a1, a1, a3
952 ; RV32I-NEXT: add a1, a1, a2
953 ; RV32I-NEXT: slli a2, a0, 8
954 ; RV32I-NEXT: slli a3, a0, 12
955 ; RV32I-NEXT: add a0, a3, a2
956 ; RV32I-NEXT: sltu a2, a0, a3
957 ; RV32I-NEXT: add a1, a1, a2
960 ; RV32IM-LABEL: muli64_p4352:
962 ; RV32IM-NEXT: li a2, 17
963 ; RV32IM-NEXT: slli a2, a2, 8
964 ; RV32IM-NEXT: mul a1, a1, a2
965 ; RV32IM-NEXT: mulhu a3, a0, a2
966 ; RV32IM-NEXT: add a1, a3, a1
967 ; RV32IM-NEXT: mul a0, a0, a2
970 ; RV64I-LABEL: muli64_p4352:
972 ; RV64I-NEXT: slli a1, a0, 8
973 ; RV64I-NEXT: slli a0, a0, 12
974 ; RV64I-NEXT: add a0, a0, a1
977 ; RV64IM-LABEL: muli64_p4352:
979 ; RV64IM-NEXT: slli a1, a0, 8
980 ; RV64IM-NEXT: slli a0, a0, 12
981 ; RV64IM-NEXT: add a0, a0, a1
983 %1 = mul i64 %a, 4352
987 define i64 @muli64_p3840(i64 %a) nounwind {
988 ; RV32I-LABEL: muli64_p3840:
990 ; RV32I-NEXT: srli a2, a0, 24
991 ; RV32I-NEXT: slli a3, a1, 8
992 ; RV32I-NEXT: or a2, a3, a2
993 ; RV32I-NEXT: srli a3, a0, 20
994 ; RV32I-NEXT: slli a1, a1, 12
995 ; RV32I-NEXT: or a1, a1, a3
996 ; RV32I-NEXT: sub a1, a1, a2
997 ; RV32I-NEXT: slli a2, a0, 8
998 ; RV32I-NEXT: slli a0, a0, 12
999 ; RV32I-NEXT: sltu a3, a0, a2
1000 ; RV32I-NEXT: sub a1, a1, a3
1001 ; RV32I-NEXT: sub a0, a0, a2
1004 ; RV32IM-LABEL: muli64_p3840:
1006 ; RV32IM-NEXT: li a2, 15
1007 ; RV32IM-NEXT: slli a2, a2, 8
1008 ; RV32IM-NEXT: mul a1, a1, a2
1009 ; RV32IM-NEXT: mulhu a3, a0, a2
1010 ; RV32IM-NEXT: add a1, a3, a1
1011 ; RV32IM-NEXT: mul a0, a0, a2
1014 ; RV64I-LABEL: muli64_p3840:
1016 ; RV64I-NEXT: slli a1, a0, 8
1017 ; RV64I-NEXT: slli a0, a0, 12
1018 ; RV64I-NEXT: sub a0, a0, a1
1021 ; RV64IM-LABEL: muli64_p3840:
1023 ; RV64IM-NEXT: slli a1, a0, 8
1024 ; RV64IM-NEXT: slli a0, a0, 12
1025 ; RV64IM-NEXT: sub a0, a0, a1
1027 %1 = mul i64 %a, 3840
1031 define i64 @muli64_m4352(i64 %a) nounwind {
1032 ; RV32I-LABEL: muli64_m4352:
1034 ; RV32I-NEXT: addi sp, sp, -16
1035 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1036 ; RV32I-NEXT: li a2, -17
1037 ; RV32I-NEXT: slli a2, a2, 8
1038 ; RV32I-NEXT: li a3, -1
1039 ; RV32I-NEXT: call __muldi3@plt
1040 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1041 ; RV32I-NEXT: addi sp, sp, 16
1044 ; RV32IM-LABEL: muli64_m4352:
1046 ; RV32IM-NEXT: li a2, -17
1047 ; RV32IM-NEXT: slli a2, a2, 8
1048 ; RV32IM-NEXT: mul a1, a1, a2
1049 ; RV32IM-NEXT: mulhu a3, a0, a2
1050 ; RV32IM-NEXT: sub a3, a3, a0
1051 ; RV32IM-NEXT: add a1, a3, a1
1052 ; RV32IM-NEXT: mul a0, a0, a2
1055 ; RV64I-LABEL: muli64_m4352:
1057 ; RV64I-NEXT: li a1, -17
1058 ; RV64I-NEXT: slli a1, a1, 8
1059 ; RV64I-NEXT: tail __muldi3@plt
1061 ; RV64IM-LABEL: muli64_m4352:
1063 ; RV64IM-NEXT: li a1, -17
1064 ; RV64IM-NEXT: slli a1, a1, 8
1065 ; RV64IM-NEXT: mul a0, a0, a1
1067 %1 = mul i64 %a, -4352
1071 define i64 @muli64_m3840(i64 %a) nounwind {
1072 ; RV32I-LABEL: muli64_m3840:
1074 ; RV32I-NEXT: srli a2, a0, 20
1075 ; RV32I-NEXT: slli a3, a1, 12
1076 ; RV32I-NEXT: or a2, a3, a2
1077 ; RV32I-NEXT: srli a3, a0, 24
1078 ; RV32I-NEXT: slli a1, a1, 8
1079 ; RV32I-NEXT: or a1, a1, a3
1080 ; RV32I-NEXT: sub a1, a1, a2
1081 ; RV32I-NEXT: slli a2, a0, 12
1082 ; RV32I-NEXT: slli a0, a0, 8
1083 ; RV32I-NEXT: sltu a3, a0, a2
1084 ; RV32I-NEXT: sub a1, a1, a3
1085 ; RV32I-NEXT: sub a0, a0, a2
1088 ; RV32IM-LABEL: muli64_m3840:
1090 ; RV32IM-NEXT: li a2, -15
1091 ; RV32IM-NEXT: slli a2, a2, 8
1092 ; RV32IM-NEXT: mul a1, a1, a2
1093 ; RV32IM-NEXT: mulhu a3, a0, a2
1094 ; RV32IM-NEXT: sub a3, a3, a0
1095 ; RV32IM-NEXT: add a1, a3, a1
1096 ; RV32IM-NEXT: mul a0, a0, a2
1099 ; RV64I-LABEL: muli64_m3840:
1101 ; RV64I-NEXT: slli a1, a0, 12
1102 ; RV64I-NEXT: slli a0, a0, 8
1103 ; RV64I-NEXT: sub a0, a0, a1
1106 ; RV64IM-LABEL: muli64_m3840:
1108 ; RV64IM-NEXT: slli a1, a0, 12
1109 ; RV64IM-NEXT: slli a0, a0, 8
1110 ; RV64IM-NEXT: sub a0, a0, a1
1112 %1 = mul i64 %a, -3840
1116 define i128 @muli128_m3840(i128 %a) nounwind {
1117 ; RV32I-LABEL: muli128_m3840:
1119 ; RV32I-NEXT: lw a4, 4(a1)
1120 ; RV32I-NEXT: lw a3, 8(a1)
1121 ; RV32I-NEXT: lw a6, 0(a1)
1122 ; RV32I-NEXT: lw a5, 12(a1)
1123 ; RV32I-NEXT: srli a1, a4, 20
1124 ; RV32I-NEXT: slli a2, a3, 12
1125 ; RV32I-NEXT: or a1, a2, a1
1126 ; RV32I-NEXT: srli a2, a4, 24
1127 ; RV32I-NEXT: slli a7, a3, 8
1128 ; RV32I-NEXT: or a2, a7, a2
1129 ; RV32I-NEXT: sltu t0, a2, a1
1130 ; RV32I-NEXT: srli a7, a3, 20
1131 ; RV32I-NEXT: slli t1, a5, 12
1132 ; RV32I-NEXT: or a7, t1, a7
1133 ; RV32I-NEXT: srli a3, a3, 24
1134 ; RV32I-NEXT: slli a5, a5, 8
1135 ; RV32I-NEXT: or a3, a5, a3
1136 ; RV32I-NEXT: sub t1, a3, a7
1137 ; RV32I-NEXT: srli a3, a6, 20
1138 ; RV32I-NEXT: slli a5, a4, 12
1139 ; RV32I-NEXT: or a3, a5, a3
1140 ; RV32I-NEXT: srli a5, a6, 24
1141 ; RV32I-NEXT: slli a4, a4, 8
1142 ; RV32I-NEXT: or a5, a4, a5
1143 ; RV32I-NEXT: slli a4, a6, 12
1144 ; RV32I-NEXT: slli a6, a6, 8
1145 ; RV32I-NEXT: sltu a7, a6, a4
1146 ; RV32I-NEXT: sub t0, t1, t0
1147 ; RV32I-NEXT: mv t1, a7
1148 ; RV32I-NEXT: beq a5, a3, .LBB30_2
1149 ; RV32I-NEXT: # %bb.1:
1150 ; RV32I-NEXT: sltu t1, a5, a3
1151 ; RV32I-NEXT: .LBB30_2:
1152 ; RV32I-NEXT: sub a2, a2, a1
1153 ; RV32I-NEXT: sltu a1, a2, t1
1154 ; RV32I-NEXT: sub a1, t0, a1
1155 ; RV32I-NEXT: sub a2, a2, t1
1156 ; RV32I-NEXT: sub a5, a5, a3
1157 ; RV32I-NEXT: sub a3, a5, a7
1158 ; RV32I-NEXT: sub a4, a6, a4
1159 ; RV32I-NEXT: sw a4, 0(a0)
1160 ; RV32I-NEXT: sw a3, 4(a0)
1161 ; RV32I-NEXT: sw a2, 8(a0)
1162 ; RV32I-NEXT: sw a1, 12(a0)
1165 ; RV32IM-LABEL: muli128_m3840:
1167 ; RV32IM-NEXT: addi sp, sp, -16
1168 ; RV32IM-NEXT: sw s0, 12(sp) # 4-byte Folded Spill
1169 ; RV32IM-NEXT: sw s1, 8(sp) # 4-byte Folded Spill
1170 ; RV32IM-NEXT: lw a2, 12(a1)
1171 ; RV32IM-NEXT: lw a3, 8(a1)
1172 ; RV32IM-NEXT: lw a4, 0(a1)
1173 ; RV32IM-NEXT: lw a1, 4(a1)
1174 ; RV32IM-NEXT: li a5, -15
1175 ; RV32IM-NEXT: slli a5, a5, 8
1176 ; RV32IM-NEXT: mulhu a6, a4, a5
1177 ; RV32IM-NEXT: mul a7, a1, a5
1178 ; RV32IM-NEXT: add a6, a7, a6
1179 ; RV32IM-NEXT: sltu a7, a6, a7
1180 ; RV32IM-NEXT: mulhu t0, a1, a5
1181 ; RV32IM-NEXT: add a7, t0, a7
1182 ; RV32IM-NEXT: sub a6, a6, a4
1183 ; RV32IM-NEXT: neg t0, a4
1184 ; RV32IM-NEXT: sltu t1, a6, t0
1185 ; RV32IM-NEXT: li t2, -1
1186 ; RV32IM-NEXT: mulhu t3, a4, t2
1187 ; RV32IM-NEXT: add t1, t3, t1
1188 ; RV32IM-NEXT: add t1, a7, t1
1189 ; RV32IM-NEXT: sub t4, t1, a1
1190 ; RV32IM-NEXT: mul t5, a3, a5
1191 ; RV32IM-NEXT: sub t5, t5, a4
1192 ; RV32IM-NEXT: add t6, t4, t5
1193 ; RV32IM-NEXT: sltu s0, t6, t4
1194 ; RV32IM-NEXT: neg s1, a1
1195 ; RV32IM-NEXT: sltu t4, t4, s1
1196 ; RV32IM-NEXT: sltu a7, t1, a7
1197 ; RV32IM-NEXT: mulhu t1, a1, t2
1198 ; RV32IM-NEXT: add a7, t1, a7
1199 ; RV32IM-NEXT: add a7, a7, t4
1200 ; RV32IM-NEXT: sltu t0, t5, t0
1201 ; RV32IM-NEXT: mul a2, a2, a5
1202 ; RV32IM-NEXT: mulhu t1, a3, a5
1203 ; RV32IM-NEXT: sub a3, t1, a3
1204 ; RV32IM-NEXT: add a2, a3, a2
1205 ; RV32IM-NEXT: add a1, a4, a1
1206 ; RV32IM-NEXT: sub a1, t3, a1
1207 ; RV32IM-NEXT: add a1, a1, a2
1208 ; RV32IM-NEXT: add a1, a1, t0
1209 ; RV32IM-NEXT: add a1, a7, a1
1210 ; RV32IM-NEXT: add a1, a1, s0
1211 ; RV32IM-NEXT: mul a2, a4, a5
1212 ; RV32IM-NEXT: sw a2, 0(a0)
1213 ; RV32IM-NEXT: sw a6, 4(a0)
1214 ; RV32IM-NEXT: sw t6, 8(a0)
1215 ; RV32IM-NEXT: sw a1, 12(a0)
1216 ; RV32IM-NEXT: lw s0, 12(sp) # 4-byte Folded Reload
1217 ; RV32IM-NEXT: lw s1, 8(sp) # 4-byte Folded Reload
1218 ; RV32IM-NEXT: addi sp, sp, 16
1221 ; RV64I-LABEL: muli128_m3840:
1223 ; RV64I-NEXT: srli a2, a0, 52
1224 ; RV64I-NEXT: slli a3, a1, 12
1225 ; RV64I-NEXT: or a2, a3, a2
1226 ; RV64I-NEXT: srli a3, a0, 56
1227 ; RV64I-NEXT: slli a1, a1, 8
1228 ; RV64I-NEXT: or a1, a1, a3
1229 ; RV64I-NEXT: sub a1, a1, a2
1230 ; RV64I-NEXT: slli a2, a0, 12
1231 ; RV64I-NEXT: slli a0, a0, 8
1232 ; RV64I-NEXT: sltu a3, a0, a2
1233 ; RV64I-NEXT: sub a1, a1, a3
1234 ; RV64I-NEXT: sub a0, a0, a2
1237 ; RV64IM-LABEL: muli128_m3840:
1239 ; RV64IM-NEXT: li a2, -15
1240 ; RV64IM-NEXT: slli a2, a2, 8
1241 ; RV64IM-NEXT: mul a1, a1, a2
1242 ; RV64IM-NEXT: mulhu a3, a0, a2
1243 ; RV64IM-NEXT: sub a3, a3, a0
1244 ; RV64IM-NEXT: add a1, a3, a1
1245 ; RV64IM-NEXT: mul a0, a0, a2
1247 %1 = mul i128 %a, -3840
1251 define i128 @muli128_m63(i128 %a) nounwind {
1252 ; RV32I-LABEL: muli128_m63:
1254 ; RV32I-NEXT: lw a2, 0(a1)
1255 ; RV32I-NEXT: lw a4, 12(a1)
1256 ; RV32I-NEXT: lw a6, 8(a1)
1257 ; RV32I-NEXT: lw a1, 4(a1)
1258 ; RV32I-NEXT: slli a3, a2, 6
1259 ; RV32I-NEXT: sltu a5, a2, a3
1260 ; RV32I-NEXT: srli a7, a2, 26
1261 ; RV32I-NEXT: slli t0, a1, 6
1262 ; RV32I-NEXT: or a7, t0, a7
1263 ; RV32I-NEXT: mv t0, a5
1264 ; RV32I-NEXT: beq a1, a7, .LBB31_2
1265 ; RV32I-NEXT: # %bb.1:
1266 ; RV32I-NEXT: sltu t0, a1, a7
1267 ; RV32I-NEXT: .LBB31_2:
1268 ; RV32I-NEXT: srli t1, a1, 26
1269 ; RV32I-NEXT: slli t2, a6, 6
1270 ; RV32I-NEXT: or t1, t2, t1
1271 ; RV32I-NEXT: sub t2, a6, t1
1272 ; RV32I-NEXT: sltu t3, t2, t0
1273 ; RV32I-NEXT: sltu t1, a6, t1
1274 ; RV32I-NEXT: srli a6, a6, 26
1275 ; RV32I-NEXT: slli t4, a4, 6
1276 ; RV32I-NEXT: or a6, t4, a6
1277 ; RV32I-NEXT: sub a4, a4, a6
1278 ; RV32I-NEXT: sub a4, a4, t1
1279 ; RV32I-NEXT: sub a4, a4, t3
1280 ; RV32I-NEXT: sub a6, t2, t0
1281 ; RV32I-NEXT: sub a1, a1, a7
1282 ; RV32I-NEXT: sub a1, a1, a5
1283 ; RV32I-NEXT: sub a2, a2, a3
1284 ; RV32I-NEXT: sw a2, 0(a0)
1285 ; RV32I-NEXT: sw a1, 4(a0)
1286 ; RV32I-NEXT: sw a6, 8(a0)
1287 ; RV32I-NEXT: sw a4, 12(a0)
1290 ; RV32IM-LABEL: muli128_m63:
1292 ; RV32IM-NEXT: addi sp, sp, -16
1293 ; RV32IM-NEXT: sw s0, 12(sp) # 4-byte Folded Spill
1294 ; RV32IM-NEXT: sw s1, 8(sp) # 4-byte Folded Spill
1295 ; RV32IM-NEXT: lw a2, 12(a1)
1296 ; RV32IM-NEXT: lw a3, 0(a1)
1297 ; RV32IM-NEXT: lw a4, 4(a1)
1298 ; RV32IM-NEXT: lw a1, 8(a1)
1299 ; RV32IM-NEXT: li a5, -63
1300 ; RV32IM-NEXT: mulhu a6, a3, a5
1301 ; RV32IM-NEXT: slli a7, a4, 6
1302 ; RV32IM-NEXT: sub a7, a4, a7
1303 ; RV32IM-NEXT: add a6, a7, a6
1304 ; RV32IM-NEXT: sltu a7, a6, a7
1305 ; RV32IM-NEXT: mulhu t0, a4, a5
1306 ; RV32IM-NEXT: add a7, t0, a7
1307 ; RV32IM-NEXT: sub a6, a6, a3
1308 ; RV32IM-NEXT: neg t0, a3
1309 ; RV32IM-NEXT: sltu t1, a6, t0
1310 ; RV32IM-NEXT: li t2, -1
1311 ; RV32IM-NEXT: mulhu t3, a3, t2
1312 ; RV32IM-NEXT: add t1, t3, t1
1313 ; RV32IM-NEXT: add t1, a7, t1
1314 ; RV32IM-NEXT: sub t4, t1, a4
1315 ; RV32IM-NEXT: slli t5, a1, 6
1316 ; RV32IM-NEXT: sub t6, a1, a3
1317 ; RV32IM-NEXT: sub t5, t6, t5
1318 ; RV32IM-NEXT: add t6, t4, t5
1319 ; RV32IM-NEXT: sltu s0, t6, t4
1320 ; RV32IM-NEXT: neg s1, a4
1321 ; RV32IM-NEXT: sltu t4, t4, s1
1322 ; RV32IM-NEXT: sltu a7, t1, a7
1323 ; RV32IM-NEXT: mulhu t1, a4, t2
1324 ; RV32IM-NEXT: add a7, t1, a7
1325 ; RV32IM-NEXT: add a7, a7, t4
1326 ; RV32IM-NEXT: sltu t0, t5, t0
1327 ; RV32IM-NEXT: slli t1, a2, 6
1328 ; RV32IM-NEXT: sub a2, a2, t1
1329 ; RV32IM-NEXT: mulhu a5, a1, a5
1330 ; RV32IM-NEXT: sub a5, a5, a1
1331 ; RV32IM-NEXT: add a2, a5, a2
1332 ; RV32IM-NEXT: add a4, a3, a4
1333 ; RV32IM-NEXT: sub a1, t3, a4
1334 ; RV32IM-NEXT: add a1, a1, a2
1335 ; RV32IM-NEXT: add a1, a1, t0
1336 ; RV32IM-NEXT: add a1, a7, a1
1337 ; RV32IM-NEXT: add a1, a1, s0
1338 ; RV32IM-NEXT: slli a2, a3, 6
1339 ; RV32IM-NEXT: sub a3, a3, a2
1340 ; RV32IM-NEXT: sw a3, 0(a0)
1341 ; RV32IM-NEXT: sw a6, 4(a0)
1342 ; RV32IM-NEXT: sw t6, 8(a0)
1343 ; RV32IM-NEXT: sw a1, 12(a0)
1344 ; RV32IM-NEXT: lw s0, 12(sp) # 4-byte Folded Reload
1345 ; RV32IM-NEXT: lw s1, 8(sp) # 4-byte Folded Reload
1346 ; RV32IM-NEXT: addi sp, sp, 16
1349 ; RV64I-LABEL: muli128_m63:
1351 ; RV64I-NEXT: slli a2, a0, 6
1352 ; RV64I-NEXT: sltu a3, a0, a2
1353 ; RV64I-NEXT: srli a4, a0, 58
1354 ; RV64I-NEXT: slli a5, a1, 6
1355 ; RV64I-NEXT: or a4, a5, a4
1356 ; RV64I-NEXT: sub a1, a1, a4
1357 ; RV64I-NEXT: sub a1, a1, a3
1358 ; RV64I-NEXT: sub a0, a0, a2
1361 ; RV64IM-LABEL: muli128_m63:
1363 ; RV64IM-NEXT: slli a2, a1, 6
1364 ; RV64IM-NEXT: sub a1, a1, a2
1365 ; RV64IM-NEXT: li a2, -63
1366 ; RV64IM-NEXT: mulhu a2, a0, a2
1367 ; RV64IM-NEXT: sub a2, a2, a0
1368 ; RV64IM-NEXT: add a1, a2, a1
1369 ; RV64IM-NEXT: slli a2, a0, 6
1370 ; RV64IM-NEXT: sub a0, a0, a2
1372 %1 = mul i128 %a, -63
1376 define i64 @mulhsu_i64(i64 %a, i64 %b) nounwind {
1377 ; RV32I-LABEL: mulhsu_i64:
1379 ; RV32I-NEXT: addi sp, sp, -48
1380 ; RV32I-NEXT: sw ra, 44(sp) # 4-byte Folded Spill
1381 ; RV32I-NEXT: sw s0, 40(sp) # 4-byte Folded Spill
1382 ; RV32I-NEXT: sw s1, 36(sp) # 4-byte Folded Spill
1383 ; RV32I-NEXT: sw s2, 32(sp) # 4-byte Folded Spill
1384 ; RV32I-NEXT: sw s3, 28(sp) # 4-byte Folded Spill
1385 ; RV32I-NEXT: sw s4, 24(sp) # 4-byte Folded Spill
1386 ; RV32I-NEXT: sw s5, 20(sp) # 4-byte Folded Spill
1387 ; RV32I-NEXT: sw s6, 16(sp) # 4-byte Folded Spill
1388 ; RV32I-NEXT: sw s7, 12(sp) # 4-byte Folded Spill
1389 ; RV32I-NEXT: sw s8, 8(sp) # 4-byte Folded Spill
1390 ; RV32I-NEXT: sw s9, 4(sp) # 4-byte Folded Spill
1391 ; RV32I-NEXT: mv s2, a3
1392 ; RV32I-NEXT: mv s3, a2
1393 ; RV32I-NEXT: mv s0, a1
1394 ; RV32I-NEXT: mv s1, a0
1395 ; RV32I-NEXT: srai s4, a3, 31
1396 ; RV32I-NEXT: li a1, 0
1397 ; RV32I-NEXT: li a3, 0
1398 ; RV32I-NEXT: call __muldi3@plt
1399 ; RV32I-NEXT: mv s5, a1
1400 ; RV32I-NEXT: mv a0, s0
1401 ; RV32I-NEXT: li a1, 0
1402 ; RV32I-NEXT: mv a2, s3
1403 ; RV32I-NEXT: li a3, 0
1404 ; RV32I-NEXT: call __muldi3@plt
1405 ; RV32I-NEXT: add s5, a0, s5
1406 ; RV32I-NEXT: sltu a0, s5, a0
1407 ; RV32I-NEXT: add s7, a1, a0
1408 ; RV32I-NEXT: mv a0, s1
1409 ; RV32I-NEXT: li a1, 0
1410 ; RV32I-NEXT: mv a2, s2
1411 ; RV32I-NEXT: li a3, 0
1412 ; RV32I-NEXT: call __muldi3@plt
1413 ; RV32I-NEXT: add s5, a0, s5
1414 ; RV32I-NEXT: sltu a0, s5, a0
1415 ; RV32I-NEXT: add a0, a1, a0
1416 ; RV32I-NEXT: add s8, s7, a0
1417 ; RV32I-NEXT: mv a0, s0
1418 ; RV32I-NEXT: li a1, 0
1419 ; RV32I-NEXT: mv a2, s2
1420 ; RV32I-NEXT: li a3, 0
1421 ; RV32I-NEXT: call __muldi3@plt
1422 ; RV32I-NEXT: mv s5, a0
1423 ; RV32I-NEXT: mv s6, a1
1424 ; RV32I-NEXT: add s9, a0, s8
1425 ; RV32I-NEXT: mv a0, s3
1426 ; RV32I-NEXT: mv a1, s2
1427 ; RV32I-NEXT: li a2, 0
1428 ; RV32I-NEXT: li a3, 0
1429 ; RV32I-NEXT: call __muldi3@plt
1430 ; RV32I-NEXT: mv s2, a0
1431 ; RV32I-NEXT: mv s3, a1
1432 ; RV32I-NEXT: mv a0, s4
1433 ; RV32I-NEXT: mv a1, s4
1434 ; RV32I-NEXT: mv a2, s1
1435 ; RV32I-NEXT: mv a3, s0
1436 ; RV32I-NEXT: call __muldi3@plt
1437 ; RV32I-NEXT: add s2, a0, s2
1438 ; RV32I-NEXT: add a2, s9, s2
1439 ; RV32I-NEXT: sltu a3, a2, s9
1440 ; RV32I-NEXT: sltu a4, s9, s5
1441 ; RV32I-NEXT: sltu a5, s8, s7
1442 ; RV32I-NEXT: add a5, s6, a5
1443 ; RV32I-NEXT: add a4, a5, a4
1444 ; RV32I-NEXT: add a1, a1, s3
1445 ; RV32I-NEXT: sltu a0, s2, a0
1446 ; RV32I-NEXT: add a0, a1, a0
1447 ; RV32I-NEXT: add a0, a4, a0
1448 ; RV32I-NEXT: add a1, a0, a3
1449 ; RV32I-NEXT: mv a0, a2
1450 ; RV32I-NEXT: lw ra, 44(sp) # 4-byte Folded Reload
1451 ; RV32I-NEXT: lw s0, 40(sp) # 4-byte Folded Reload
1452 ; RV32I-NEXT: lw s1, 36(sp) # 4-byte Folded Reload
1453 ; RV32I-NEXT: lw s2, 32(sp) # 4-byte Folded Reload
1454 ; RV32I-NEXT: lw s3, 28(sp) # 4-byte Folded Reload
1455 ; RV32I-NEXT: lw s4, 24(sp) # 4-byte Folded Reload
1456 ; RV32I-NEXT: lw s5, 20(sp) # 4-byte Folded Reload
1457 ; RV32I-NEXT: lw s6, 16(sp) # 4-byte Folded Reload
1458 ; RV32I-NEXT: lw s7, 12(sp) # 4-byte Folded Reload
1459 ; RV32I-NEXT: lw s8, 8(sp) # 4-byte Folded Reload
1460 ; RV32I-NEXT: lw s9, 4(sp) # 4-byte Folded Reload
1461 ; RV32I-NEXT: addi sp, sp, 48
1464 ; RV32IM-LABEL: mulhsu_i64:
1466 ; RV32IM-NEXT: srai a4, a3, 31
1467 ; RV32IM-NEXT: mulhu a5, a0, a2
1468 ; RV32IM-NEXT: mul a6, a1, a2
1469 ; RV32IM-NEXT: add a5, a6, a5
1470 ; RV32IM-NEXT: sltu a6, a5, a6
1471 ; RV32IM-NEXT: mulhu a2, a1, a2
1472 ; RV32IM-NEXT: add a6, a2, a6
1473 ; RV32IM-NEXT: mul a2, a0, a3
1474 ; RV32IM-NEXT: add a5, a2, a5
1475 ; RV32IM-NEXT: sltu a2, a5, a2
1476 ; RV32IM-NEXT: mulhu a5, a0, a3
1477 ; RV32IM-NEXT: add a2, a5, a2
1478 ; RV32IM-NEXT: add a5, a6, a2
1479 ; RV32IM-NEXT: mul a7, a1, a3
1480 ; RV32IM-NEXT: add t0, a7, a5
1481 ; RV32IM-NEXT: mul t1, a4, a0
1482 ; RV32IM-NEXT: add a2, t0, t1
1483 ; RV32IM-NEXT: sltu t2, a2, t0
1484 ; RV32IM-NEXT: sltu a7, t0, a7
1485 ; RV32IM-NEXT: sltu a5, a5, a6
1486 ; RV32IM-NEXT: mulhu a3, a1, a3
1487 ; RV32IM-NEXT: add a3, a3, a5
1488 ; RV32IM-NEXT: add a3, a3, a7
1489 ; RV32IM-NEXT: mul a1, a4, a1
1490 ; RV32IM-NEXT: mulhu a0, a4, a0
1491 ; RV32IM-NEXT: add a0, a0, a1
1492 ; RV32IM-NEXT: add a0, a0, t1
1493 ; RV32IM-NEXT: add a0, a3, a0
1494 ; RV32IM-NEXT: add a1, a0, t2
1495 ; RV32IM-NEXT: mv a0, a2
1498 ; RV64I-LABEL: mulhsu_i64:
1500 ; RV64I-NEXT: addi sp, sp, -16
1501 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
1502 ; RV64I-NEXT: mv a2, a1
1503 ; RV64I-NEXT: srai a3, a1, 63
1504 ; RV64I-NEXT: li a1, 0
1505 ; RV64I-NEXT: call __multi3@plt
1506 ; RV64I-NEXT: mv a0, a1
1507 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
1508 ; RV64I-NEXT: addi sp, sp, 16
1511 ; RV64IM-LABEL: mulhsu_i64:
1513 ; RV64IM-NEXT: mulhsu a0, a1, a0
1515 %1 = zext i64 %a to i128
1516 %2 = sext i64 %b to i128
1517 %3 = mul i128 %1, %2
1518 %4 = lshr i128 %3, 64
1519 %5 = trunc i128 %4 to i64
1523 define i8 @muladd_demand(i8 %x, i8 %y) nounwind {
1524 ; RV32I-LABEL: muladd_demand:
1526 ; RV32I-NEXT: slli a0, a0, 1
1527 ; RV32I-NEXT: sub a0, a1, a0
1528 ; RV32I-NEXT: andi a0, a0, 15
1531 ; RV32IM-LABEL: muladd_demand:
1533 ; RV32IM-NEXT: slli a0, a0, 1
1534 ; RV32IM-NEXT: sub a0, a1, a0
1535 ; RV32IM-NEXT: andi a0, a0, 15
1538 ; RV64I-LABEL: muladd_demand:
1540 ; RV64I-NEXT: slli a0, a0, 1
1541 ; RV64I-NEXT: subw a0, a1, a0
1542 ; RV64I-NEXT: andi a0, a0, 15
1545 ; RV64IM-LABEL: muladd_demand:
1547 ; RV64IM-NEXT: slli a0, a0, 1
1548 ; RV64IM-NEXT: subw a0, a1, a0
1549 ; RV64IM-NEXT: andi a0, a0, 15
1557 define i8 @mulsub_demand(i8 %x, i8 %y) nounwind {
1558 ; RV32I-LABEL: mulsub_demand:
1560 ; RV32I-NEXT: slli a0, a0, 1
1561 ; RV32I-NEXT: add a0, a1, a0
1562 ; RV32I-NEXT: andi a0, a0, 15
1565 ; RV32IM-LABEL: mulsub_demand:
1567 ; RV32IM-NEXT: slli a0, a0, 1
1568 ; RV32IM-NEXT: add a0, a1, a0
1569 ; RV32IM-NEXT: andi a0, a0, 15
1572 ; RV64I-LABEL: mulsub_demand:
1574 ; RV64I-NEXT: slli a0, a0, 1
1575 ; RV64I-NEXT: add a0, a1, a0
1576 ; RV64I-NEXT: andi a0, a0, 15
1579 ; RV64IM-LABEL: mulsub_demand:
1581 ; RV64IM-NEXT: slli a0, a0, 1
1582 ; RV64IM-NEXT: add a0, a1, a0
1583 ; RV64IM-NEXT: andi a0, a0, 15
1591 define i8 @muladd_demand_2(i8 %x, i8 %y) nounwind {
1592 ; RV32I-LABEL: muladd_demand_2:
1594 ; RV32I-NEXT: slli a0, a0, 1
1595 ; RV32I-NEXT: sub a1, a1, a0
1596 ; RV32I-NEXT: ori a0, a1, -16
1599 ; RV32IM-LABEL: muladd_demand_2:
1601 ; RV32IM-NEXT: slli a0, a0, 1
1602 ; RV32IM-NEXT: sub a1, a1, a0
1603 ; RV32IM-NEXT: ori a0, a1, -16
1606 ; RV64I-LABEL: muladd_demand_2:
1608 ; RV64I-NEXT: slli a0, a0, 1
1609 ; RV64I-NEXT: subw a1, a1, a0
1610 ; RV64I-NEXT: ori a0, a1, -16
1613 ; RV64IM-LABEL: muladd_demand_2:
1615 ; RV64IM-NEXT: slli a0, a0, 1
1616 ; RV64IM-NEXT: subw a1, a1, a0
1617 ; RV64IM-NEXT: ori a0, a1, -16
1625 define i8 @mulsub_demand_2(i8 %x, i8 %y) nounwind {
1626 ; RV32I-LABEL: mulsub_demand_2:
1628 ; RV32I-NEXT: slli a0, a0, 1
1629 ; RV32I-NEXT: add a0, a1, a0
1630 ; RV32I-NEXT: ori a0, a0, -16
1633 ; RV32IM-LABEL: mulsub_demand_2:
1635 ; RV32IM-NEXT: slli a0, a0, 1
1636 ; RV32IM-NEXT: add a0, a1, a0
1637 ; RV32IM-NEXT: ori a0, a0, -16
1640 ; RV64I-LABEL: mulsub_demand_2:
1642 ; RV64I-NEXT: slli a0, a0, 1
1643 ; RV64I-NEXT: add a0, a1, a0
1644 ; RV64I-NEXT: ori a0, a0, -16
1647 ; RV64IM-LABEL: mulsub_demand_2:
1649 ; RV64IM-NEXT: slli a0, a0, 1
1650 ; RV64IM-NEXT: add a0, a1, a0
1651 ; RV64IM-NEXT: ori a0, a0, -16