1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefix=RV64I
5 ; The patterns for the 'W' suffixed RV64I instructions have the potential of
6 ; missing cases. This file checks all the variants of
7 ; sign-extended/zero-extended/any-extended inputs and outputs.
9 ; The 64-bit add instruction can safely be used when the result is anyext.
11 define i32 @aext_addw_aext_aext(i32 %a, i32 %b) nounwind {
12 ; RV64I-LABEL: aext_addw_aext_aext:
14 ; RV64I-NEXT: addw a0, a0, a1
20 define i32 @aext_addw_aext_sext(i32 %a, i32 signext %b) nounwind {
21 ; RV64I-LABEL: aext_addw_aext_sext:
23 ; RV64I-NEXT: addw a0, a0, a1
29 define i32 @aext_addw_aext_zext(i32 %a, i32 zeroext %b) nounwind {
30 ; RV64I-LABEL: aext_addw_aext_zext:
32 ; RV64I-NEXT: addw a0, a0, a1
38 define i32 @aext_addw_sext_aext(i32 signext %a, i32 %b) nounwind {
39 ; RV64I-LABEL: aext_addw_sext_aext:
41 ; RV64I-NEXT: addw a0, a0, a1
47 define i32 @aext_addw_sext_sext(i32 signext %a, i32 signext %b) nounwind {
48 ; RV64I-LABEL: aext_addw_sext_sext:
50 ; RV64I-NEXT: addw a0, a0, a1
56 define i32 @aext_addw_sext_zext(i32 signext %a, i32 zeroext %b) nounwind {
57 ; RV64I-LABEL: aext_addw_sext_zext:
59 ; RV64I-NEXT: addw a0, a0, a1
65 define i32 @aext_addw_zext_aext(i32 zeroext %a, i32 %b) nounwind {
66 ; RV64I-LABEL: aext_addw_zext_aext:
68 ; RV64I-NEXT: addw a0, a0, a1
74 define i32 @aext_addw_zext_sext(i32 zeroext %a, i32 signext %b) nounwind {
75 ; RV64I-LABEL: aext_addw_zext_sext:
77 ; RV64I-NEXT: addw a0, a0, a1
83 define i32 @aext_addw_zext_zext(i32 zeroext %a, i32 zeroext %b) nounwind {
84 ; RV64I-LABEL: aext_addw_zext_zext:
86 ; RV64I-NEXT: addw a0, a0, a1
92 ; Always select addw when a signext result is required.
94 define signext i32 @sext_addw_aext_aext(i32 %a, i32 %b) nounwind {
95 ; RV64I-LABEL: sext_addw_aext_aext:
97 ; RV64I-NEXT: addw a0, a0, a1
103 define signext i32 @sext_addw_aext_sext(i32 %a, i32 signext %b) nounwind {
104 ; RV64I-LABEL: sext_addw_aext_sext:
106 ; RV64I-NEXT: addw a0, a0, a1
112 define signext i32 @sext_addw_aext_zext(i32 %a, i32 zeroext %b) nounwind {
113 ; RV64I-LABEL: sext_addw_aext_zext:
115 ; RV64I-NEXT: addw a0, a0, a1
121 define signext i32 @sext_addw_sext_aext(i32 signext %a, i32 %b) nounwind {
122 ; RV64I-LABEL: sext_addw_sext_aext:
124 ; RV64I-NEXT: addw a0, a0, a1
130 define signext i32 @sext_addw_sext_sext(i32 signext %a, i32 signext %b) nounwind {
131 ; RV64I-LABEL: sext_addw_sext_sext:
133 ; RV64I-NEXT: addw a0, a0, a1
139 define signext i32 @sext_addw_sext_zext(i32 signext %a, i32 zeroext %b) nounwind {
140 ; RV64I-LABEL: sext_addw_sext_zext:
142 ; RV64I-NEXT: addw a0, a0, a1
148 define signext i32 @sext_addw_zext_aext(i32 zeroext %a, i32 %b) nounwind {
149 ; RV64I-LABEL: sext_addw_zext_aext:
151 ; RV64I-NEXT: addw a0, a0, a1
157 define signext i32 @sext_addw_zext_sext(i32 zeroext %a, i32 signext %b) nounwind {
158 ; RV64I-LABEL: sext_addw_zext_sext:
160 ; RV64I-NEXT: addw a0, a0, a1
166 define signext i32 @sext_addw_zext_zext(i32 zeroext %a, i32 zeroext %b) nounwind {
167 ; RV64I-LABEL: sext_addw_zext_zext:
169 ; RV64I-NEXT: addw a0, a0, a1
175 ; 64-bit add followed by zero-extension is a safe option when a zeroext result
178 define zeroext i32 @zext_addw_aext_aext(i32 %a, i32 %b) nounwind {
179 ; RV64I-LABEL: zext_addw_aext_aext:
181 ; RV64I-NEXT: add a0, a0, a1
182 ; RV64I-NEXT: slli a0, a0, 32
183 ; RV64I-NEXT: srli a0, a0, 32
189 define zeroext i32 @zext_addw_aext_sext(i32 %a, i32 signext %b) nounwind {
190 ; RV64I-LABEL: zext_addw_aext_sext:
192 ; RV64I-NEXT: add a0, a0, a1
193 ; RV64I-NEXT: slli a0, a0, 32
194 ; RV64I-NEXT: srli a0, a0, 32
200 define zeroext i32 @zext_addw_aext_zext(i32 %a, i32 zeroext %b) nounwind {
201 ; RV64I-LABEL: zext_addw_aext_zext:
203 ; RV64I-NEXT: add a0, a0, a1
204 ; RV64I-NEXT: slli a0, a0, 32
205 ; RV64I-NEXT: srli a0, a0, 32
211 define zeroext i32 @zext_addw_sext_aext(i32 signext %a, i32 %b) nounwind {
212 ; RV64I-LABEL: zext_addw_sext_aext:
214 ; RV64I-NEXT: add a0, a0, a1
215 ; RV64I-NEXT: slli a0, a0, 32
216 ; RV64I-NEXT: srli a0, a0, 32
222 define zeroext i32 @zext_addw_sext_sext(i32 signext %a, i32 signext %b) nounwind {
223 ; RV64I-LABEL: zext_addw_sext_sext:
225 ; RV64I-NEXT: add a0, a0, a1
226 ; RV64I-NEXT: slli a0, a0, 32
227 ; RV64I-NEXT: srli a0, a0, 32
233 define zeroext i32 @zext_addw_sext_zext(i32 signext %a, i32 zeroext %b) nounwind {
234 ; RV64I-LABEL: zext_addw_sext_zext:
236 ; RV64I-NEXT: add a0, a0, a1
237 ; RV64I-NEXT: slli a0, a0, 32
238 ; RV64I-NEXT: srli a0, a0, 32
244 define zeroext i32 @zext_addw_zext_aext(i32 zeroext %a, i32 %b) nounwind {
245 ; RV64I-LABEL: zext_addw_zext_aext:
247 ; RV64I-NEXT: add a0, a0, a1
248 ; RV64I-NEXT: slli a0, a0, 32
249 ; RV64I-NEXT: srli a0, a0, 32
255 define zeroext i32 @zext_addw_zext_sext(i32 zeroext %a, i32 signext %b) nounwind {
256 ; RV64I-LABEL: zext_addw_zext_sext:
258 ; RV64I-NEXT: add a0, a0, a1
259 ; RV64I-NEXT: slli a0, a0, 32
260 ; RV64I-NEXT: srli a0, a0, 32
266 define zeroext i32 @zext_addw_zext_zext(i32 zeroext %a, i32 zeroext %b) nounwind {
267 ; RV64I-LABEL: zext_addw_zext_zext:
269 ; RV64I-NEXT: add a0, a0, a1
270 ; RV64I-NEXT: slli a0, a0, 32
271 ; RV64I-NEXT: srli a0, a0, 32
277 ; 64-bit sub is safe for an anyext result.
279 define i32 @aext_subw_aext_aext(i32 %a, i32 %b) nounwind {
280 ; RV64I-LABEL: aext_subw_aext_aext:
282 ; RV64I-NEXT: subw a0, a0, a1
288 define i32 @aext_subw_aext_sext(i32 %a, i32 signext %b) nounwind {
289 ; RV64I-LABEL: aext_subw_aext_sext:
291 ; RV64I-NEXT: subw a0, a0, a1
297 define i32 @aext_subw_aext_zext(i32 %a, i32 zeroext %b) nounwind {
298 ; RV64I-LABEL: aext_subw_aext_zext:
300 ; RV64I-NEXT: subw a0, a0, a1
306 define i32 @aext_subw_sext_aext(i32 signext %a, i32 %b) nounwind {
307 ; RV64I-LABEL: aext_subw_sext_aext:
309 ; RV64I-NEXT: subw a0, a0, a1
315 define i32 @aext_subw_sext_sext(i32 signext %a, i32 signext %b) nounwind {
316 ; RV64I-LABEL: aext_subw_sext_sext:
318 ; RV64I-NEXT: subw a0, a0, a1
324 define i32 @aext_subw_sext_zext(i32 signext %a, i32 zeroext %b) nounwind {
325 ; RV64I-LABEL: aext_subw_sext_zext:
327 ; RV64I-NEXT: subw a0, a0, a1
333 define i32 @aext_subw_zext_aext(i32 zeroext %a, i32 %b) nounwind {
334 ; RV64I-LABEL: aext_subw_zext_aext:
336 ; RV64I-NEXT: subw a0, a0, a1
342 define i32 @aext_subw_zext_sext(i32 zeroext %a, i32 signext %b) nounwind {
343 ; RV64I-LABEL: aext_subw_zext_sext:
345 ; RV64I-NEXT: subw a0, a0, a1
351 define i32 @aext_subw_zext_zext(i32 zeroext %a, i32 zeroext %b) nounwind {
352 ; RV64I-LABEL: aext_subw_zext_zext:
354 ; RV64I-NEXT: subw a0, a0, a1
360 ; Always select subw for a signext result.
362 define signext i32 @sext_subw_aext_aext(i32 %a, i32 %b) nounwind {
363 ; RV64I-LABEL: sext_subw_aext_aext:
365 ; RV64I-NEXT: subw a0, a0, a1
371 define signext i32 @sext_subw_aext_sext(i32 %a, i32 signext %b) nounwind {
372 ; RV64I-LABEL: sext_subw_aext_sext:
374 ; RV64I-NEXT: subw a0, a0, a1
380 define signext i32 @sext_subw_aext_zext(i32 %a, i32 zeroext %b) nounwind {
381 ; RV64I-LABEL: sext_subw_aext_zext:
383 ; RV64I-NEXT: subw a0, a0, a1
389 define signext i32 @sext_subw_sext_aext(i32 signext %a, i32 %b) nounwind {
390 ; RV64I-LABEL: sext_subw_sext_aext:
392 ; RV64I-NEXT: subw a0, a0, a1
398 define signext i32 @sext_subw_sext_sext(i32 signext %a, i32 signext %b) nounwind {
399 ; RV64I-LABEL: sext_subw_sext_sext:
401 ; RV64I-NEXT: subw a0, a0, a1
407 define signext i32 @sext_subw_sext_zext(i32 signext %a, i32 zeroext %b) nounwind {
408 ; RV64I-LABEL: sext_subw_sext_zext:
410 ; RV64I-NEXT: subw a0, a0, a1
416 define signext i32 @sext_subw_zext_aext(i32 zeroext %a, i32 %b) nounwind {
417 ; RV64I-LABEL: sext_subw_zext_aext:
419 ; RV64I-NEXT: subw a0, a0, a1
425 define signext i32 @sext_subw_zext_sext(i32 zeroext %a, i32 signext %b) nounwind {
426 ; RV64I-LABEL: sext_subw_zext_sext:
428 ; RV64I-NEXT: subw a0, a0, a1
434 define signext i32 @sext_subw_zext_zext(i32 zeroext %a, i32 zeroext %b) nounwind {
435 ; RV64I-LABEL: sext_subw_zext_zext:
437 ; RV64I-NEXT: subw a0, a0, a1
443 ; 64-bit sub followed by zero-extension is safe for a zeroext result.
445 define zeroext i32 @zext_subw_aext_aext(i32 %a, i32 %b) nounwind {
446 ; RV64I-LABEL: zext_subw_aext_aext:
448 ; RV64I-NEXT: sub a0, a0, a1
449 ; RV64I-NEXT: slli a0, a0, 32
450 ; RV64I-NEXT: srli a0, a0, 32
456 define zeroext i32 @zext_subw_aext_sext(i32 %a, i32 signext %b) nounwind {
457 ; RV64I-LABEL: zext_subw_aext_sext:
459 ; RV64I-NEXT: sub a0, a0, a1
460 ; RV64I-NEXT: slli a0, a0, 32
461 ; RV64I-NEXT: srli a0, a0, 32
467 define zeroext i32 @zext_subw_aext_zext(i32 %a, i32 zeroext %b) nounwind {
468 ; RV64I-LABEL: zext_subw_aext_zext:
470 ; RV64I-NEXT: sub a0, a0, a1
471 ; RV64I-NEXT: slli a0, a0, 32
472 ; RV64I-NEXT: srli a0, a0, 32
478 define zeroext i32 @zext_subw_sext_aext(i32 signext %a, i32 %b) nounwind {
479 ; RV64I-LABEL: zext_subw_sext_aext:
481 ; RV64I-NEXT: sub a0, a0, a1
482 ; RV64I-NEXT: slli a0, a0, 32
483 ; RV64I-NEXT: srli a0, a0, 32
489 define zeroext i32 @zext_subw_sext_sext(i32 signext %a, i32 signext %b) nounwind {
490 ; RV64I-LABEL: zext_subw_sext_sext:
492 ; RV64I-NEXT: sub a0, a0, a1
493 ; RV64I-NEXT: slli a0, a0, 32
494 ; RV64I-NEXT: srli a0, a0, 32
500 define zeroext i32 @zext_subw_sext_zext(i32 signext %a, i32 zeroext %b) nounwind {
501 ; RV64I-LABEL: zext_subw_sext_zext:
503 ; RV64I-NEXT: sub a0, a0, a1
504 ; RV64I-NEXT: slli a0, a0, 32
505 ; RV64I-NEXT: srli a0, a0, 32
511 define zeroext i32 @zext_subw_zext_aext(i32 zeroext %a, i32 %b) nounwind {
512 ; RV64I-LABEL: zext_subw_zext_aext:
514 ; RV64I-NEXT: sub a0, a0, a1
515 ; RV64I-NEXT: slli a0, a0, 32
516 ; RV64I-NEXT: srli a0, a0, 32
522 define zeroext i32 @zext_subw_zext_sext(i32 zeroext %a, i32 signext %b) nounwind {
523 ; RV64I-LABEL: zext_subw_zext_sext:
525 ; RV64I-NEXT: sub a0, a0, a1
526 ; RV64I-NEXT: slli a0, a0, 32
527 ; RV64I-NEXT: srli a0, a0, 32
533 define zeroext i32 @zext_subw_zext_zext(i32 zeroext %a, i32 zeroext %b) nounwind {
534 ; RV64I-LABEL: zext_subw_zext_zext:
536 ; RV64I-NEXT: sub a0, a0, a1
537 ; RV64I-NEXT: slli a0, a0, 32
538 ; RV64I-NEXT: srli a0, a0, 32
544 ; 64-bit sll is a safe choice for an anyext result.
546 define i32 @aext_sllw_aext_aext(i32 %a, i32 %b) nounwind {
547 ; RV64I-LABEL: aext_sllw_aext_aext:
549 ; RV64I-NEXT: sllw a0, a0, a1
555 define i32 @aext_sllw_aext_sext(i32 %a, i32 signext %b) nounwind {
556 ; RV64I-LABEL: aext_sllw_aext_sext:
558 ; RV64I-NEXT: sllw a0, a0, a1
564 define i32 @aext_sllw_aext_zext(i32 %a, i32 zeroext %b) nounwind {
565 ; RV64I-LABEL: aext_sllw_aext_zext:
567 ; RV64I-NEXT: sllw a0, a0, a1
573 define i32 @aext_sllw_sext_aext(i32 signext %a, i32 %b) nounwind {
574 ; RV64I-LABEL: aext_sllw_sext_aext:
576 ; RV64I-NEXT: sllw a0, a0, a1
582 define i32 @aext_sllw_sext_sext(i32 signext %a, i32 signext %b) nounwind {
583 ; RV64I-LABEL: aext_sllw_sext_sext:
585 ; RV64I-NEXT: sllw a0, a0, a1
591 define i32 @aext_sllw_sext_zext(i32 signext %a, i32 zeroext %b) nounwind {
592 ; RV64I-LABEL: aext_sllw_sext_zext:
594 ; RV64I-NEXT: sllw a0, a0, a1
600 define i32 @aext_sllw_zext_aext(i32 zeroext %a, i32 %b) nounwind {
601 ; RV64I-LABEL: aext_sllw_zext_aext:
603 ; RV64I-NEXT: sllw a0, a0, a1
609 define i32 @aext_sllw_zext_sext(i32 zeroext %a, i32 signext %b) nounwind {
610 ; RV64I-LABEL: aext_sllw_zext_sext:
612 ; RV64I-NEXT: sllw a0, a0, a1
618 define i32 @aext_sllw_zext_zext(i32 zeroext %a, i32 zeroext %b) nounwind {
619 ; RV64I-LABEL: aext_sllw_zext_zext:
621 ; RV64I-NEXT: sllw a0, a0, a1
627 define signext i32 @sext_sllw_aext_aext(i32 %a, i32 %b) nounwind {
628 ; RV64I-LABEL: sext_sllw_aext_aext:
630 ; RV64I-NEXT: sllw a0, a0, a1
636 define signext i32 @sext_sllw_aext_sext(i32 %a, i32 signext %b) nounwind {
637 ; RV64I-LABEL: sext_sllw_aext_sext:
639 ; RV64I-NEXT: sllw a0, a0, a1
645 define signext i32 @sext_sllw_aext_zext(i32 %a, i32 zeroext %b) nounwind {
646 ; RV64I-LABEL: sext_sllw_aext_zext:
648 ; RV64I-NEXT: sllw a0, a0, a1
654 define signext i32 @sext_sllw_sext_aext(i32 signext %a, i32 %b) nounwind {
655 ; RV64I-LABEL: sext_sllw_sext_aext:
657 ; RV64I-NEXT: sllw a0, a0, a1
663 define signext i32 @sext_sllw_sext_sext(i32 signext %a, i32 signext %b) nounwind {
664 ; RV64I-LABEL: sext_sllw_sext_sext:
666 ; RV64I-NEXT: sllw a0, a0, a1
672 define signext i32 @sext_sllw_sext_zext(i32 signext %a, i32 zeroext %b) nounwind {
673 ; RV64I-LABEL: sext_sllw_sext_zext:
675 ; RV64I-NEXT: sllw a0, a0, a1
681 define signext i32 @sext_sllw_zext_aext(i32 zeroext %a, i32 %b) nounwind {
682 ; RV64I-LABEL: sext_sllw_zext_aext:
684 ; RV64I-NEXT: sllw a0, a0, a1
690 define signext i32 @sext_sllw_zext_sext(i32 zeroext %a, i32 signext %b) nounwind {
691 ; RV64I-LABEL: sext_sllw_zext_sext:
693 ; RV64I-NEXT: sllw a0, a0, a1
699 define signext i32 @sext_sllw_zext_zext(i32 zeroext %a, i32 zeroext %b) nounwind {
700 ; RV64I-LABEL: sext_sllw_zext_zext:
702 ; RV64I-NEXT: sllw a0, a0, a1
708 ; 64-bit sll followed by zero-extension for a zeroext result.
710 define zeroext i32 @zext_sllw_aext_aext(i32 %a, i32 %b) nounwind {
711 ; RV64I-LABEL: zext_sllw_aext_aext:
713 ; RV64I-NEXT: sllw a0, a0, a1
714 ; RV64I-NEXT: slli a0, a0, 32
715 ; RV64I-NEXT: srli a0, a0, 32
721 define zeroext i32 @zext_sllw_aext_sext(i32 %a, i32 signext %b) nounwind {
722 ; RV64I-LABEL: zext_sllw_aext_sext:
724 ; RV64I-NEXT: sllw a0, a0, a1
725 ; RV64I-NEXT: slli a0, a0, 32
726 ; RV64I-NEXT: srli a0, a0, 32
732 define zeroext i32 @zext_sllw_aext_zext(i32 %a, i32 zeroext %b) nounwind {
733 ; RV64I-LABEL: zext_sllw_aext_zext:
735 ; RV64I-NEXT: sllw a0, a0, a1
736 ; RV64I-NEXT: slli a0, a0, 32
737 ; RV64I-NEXT: srli a0, a0, 32
743 define zeroext i32 @zext_sllw_sext_aext(i32 signext %a, i32 %b) nounwind {
744 ; RV64I-LABEL: zext_sllw_sext_aext:
746 ; RV64I-NEXT: sllw a0, a0, a1
747 ; RV64I-NEXT: slli a0, a0, 32
748 ; RV64I-NEXT: srli a0, a0, 32
754 define zeroext i32 @zext_sllw_sext_sext(i32 signext %a, i32 signext %b) nounwind {
755 ; RV64I-LABEL: zext_sllw_sext_sext:
757 ; RV64I-NEXT: sllw a0, a0, a1
758 ; RV64I-NEXT: slli a0, a0, 32
759 ; RV64I-NEXT: srli a0, a0, 32
765 define zeroext i32 @zext_sllw_sext_zext(i32 signext %a, i32 zeroext %b) nounwind {
766 ; RV64I-LABEL: zext_sllw_sext_zext:
768 ; RV64I-NEXT: sllw a0, a0, a1
769 ; RV64I-NEXT: slli a0, a0, 32
770 ; RV64I-NEXT: srli a0, a0, 32
776 define zeroext i32 @zext_sllw_zext_aext(i32 zeroext %a, i32 %b) nounwind {
777 ; RV64I-LABEL: zext_sllw_zext_aext:
779 ; RV64I-NEXT: sllw a0, a0, a1
780 ; RV64I-NEXT: slli a0, a0, 32
781 ; RV64I-NEXT: srli a0, a0, 32
787 define zeroext i32 @zext_sllw_zext_sext(i32 zeroext %a, i32 signext %b) nounwind {
788 ; RV64I-LABEL: zext_sllw_zext_sext:
790 ; RV64I-NEXT: sllw a0, a0, a1
791 ; RV64I-NEXT: slli a0, a0, 32
792 ; RV64I-NEXT: srli a0, a0, 32
798 define zeroext i32 @zext_sllw_zext_zext(i32 zeroext %a, i32 zeroext %b) nounwind {
799 ; RV64I-LABEL: zext_sllw_zext_zext:
801 ; RV64I-NEXT: sllw a0, a0, a1
802 ; RV64I-NEXT: slli a0, a0, 32
803 ; RV64I-NEXT: srli a0, a0, 32
809 define i32 @aext_srlw_aext_aext(i32 %a, i32 %b) nounwind {
810 ; RV64I-LABEL: aext_srlw_aext_aext:
812 ; RV64I-NEXT: srlw a0, a0, a1
818 define i32 @aext_srlw_aext_sext(i32 %a, i32 signext %b) nounwind {
819 ; RV64I-LABEL: aext_srlw_aext_sext:
821 ; RV64I-NEXT: srlw a0, a0, a1
827 define i32 @aext_srlw_aext_zext(i32 %a, i32 zeroext %b) nounwind {
828 ; RV64I-LABEL: aext_srlw_aext_zext:
830 ; RV64I-NEXT: srlw a0, a0, a1
836 define i32 @aext_srlw_sext_aext(i32 signext %a, i32 %b) nounwind {
837 ; RV64I-LABEL: aext_srlw_sext_aext:
839 ; RV64I-NEXT: srlw a0, a0, a1
845 define i32 @aext_srlw_sext_sext(i32 signext %a, i32 signext %b) nounwind {
846 ; RV64I-LABEL: aext_srlw_sext_sext:
848 ; RV64I-NEXT: srlw a0, a0, a1
854 define i32 @aext_srlw_sext_zext(i32 signext %a, i32 zeroext %b) nounwind {
855 ; RV64I-LABEL: aext_srlw_sext_zext:
857 ; RV64I-NEXT: srlw a0, a0, a1
863 define i32 @aext_srlw_zext_aext(i32 zeroext %a, i32 %b) nounwind {
864 ; RV64I-LABEL: aext_srlw_zext_aext:
866 ; RV64I-NEXT: srlw a0, a0, a1
872 define i32 @aext_srlw_zext_sext(i32 zeroext %a, i32 signext %b) nounwind {
873 ; RV64I-LABEL: aext_srlw_zext_sext:
875 ; RV64I-NEXT: srlw a0, a0, a1
881 define i32 @aext_srlw_zext_zext(i32 zeroext %a, i32 zeroext %b) nounwind {
882 ; RV64I-LABEL: aext_srlw_zext_zext:
884 ; RV64I-NEXT: srlw a0, a0, a1
890 define signext i32 @sext_srlw_aext_aext(i32 %a, i32 %b) nounwind {
891 ; RV64I-LABEL: sext_srlw_aext_aext:
893 ; RV64I-NEXT: srlw a0, a0, a1
899 define signext i32 @sext_srlw_aext_sext(i32 %a, i32 signext %b) nounwind {
900 ; RV64I-LABEL: sext_srlw_aext_sext:
902 ; RV64I-NEXT: srlw a0, a0, a1
908 define signext i32 @sext_srlw_aext_zext(i32 %a, i32 zeroext %b) nounwind {
909 ; RV64I-LABEL: sext_srlw_aext_zext:
911 ; RV64I-NEXT: srlw a0, a0, a1
917 define signext i32 @sext_srlw_sext_aext(i32 signext %a, i32 %b) nounwind {
918 ; RV64I-LABEL: sext_srlw_sext_aext:
920 ; RV64I-NEXT: srlw a0, a0, a1
926 define signext i32 @sext_srlw_sext_sext(i32 signext %a, i32 signext %b) nounwind {
927 ; RV64I-LABEL: sext_srlw_sext_sext:
929 ; RV64I-NEXT: srlw a0, a0, a1
935 define signext i32 @sext_srlw_sext_zext(i32 signext %a, i32 zeroext %b) nounwind {
936 ; RV64I-LABEL: sext_srlw_sext_zext:
938 ; RV64I-NEXT: srlw a0, a0, a1
944 define signext i32 @sext_srlw_zext_aext(i32 zeroext %a, i32 %b) nounwind {
945 ; RV64I-LABEL: sext_srlw_zext_aext:
947 ; RV64I-NEXT: srlw a0, a0, a1
953 define signext i32 @sext_srlw_zext_sext(i32 zeroext %a, i32 signext %b) nounwind {
954 ; RV64I-LABEL: sext_srlw_zext_sext:
956 ; RV64I-NEXT: srlw a0, a0, a1
962 define signext i32 @sext_srlw_zext_zext(i32 zeroext %a, i32 zeroext %b) nounwind {
963 ; RV64I-LABEL: sext_srlw_zext_zext:
965 ; RV64I-NEXT: srlw a0, a0, a1
971 define zeroext i32 @zext_srlw_aext_aext(i32 %a, i32 %b) nounwind {
972 ; RV64I-LABEL: zext_srlw_aext_aext:
974 ; RV64I-NEXT: srlw a0, a0, a1
975 ; RV64I-NEXT: slli a0, a0, 32
976 ; RV64I-NEXT: srli a0, a0, 32
982 define zeroext i32 @zext_srlw_aext_sext(i32 %a, i32 signext %b) nounwind {
983 ; RV64I-LABEL: zext_srlw_aext_sext:
985 ; RV64I-NEXT: srlw a0, a0, a1
986 ; RV64I-NEXT: slli a0, a0, 32
987 ; RV64I-NEXT: srli a0, a0, 32
993 define zeroext i32 @zext_srlw_aext_zext(i32 %a, i32 zeroext %b) nounwind {
994 ; RV64I-LABEL: zext_srlw_aext_zext:
996 ; RV64I-NEXT: srlw a0, a0, a1
997 ; RV64I-NEXT: slli a0, a0, 32
998 ; RV64I-NEXT: srli a0, a0, 32
1000 %1 = lshr i32 %a, %b
1004 define zeroext i32 @zext_srlw_sext_aext(i32 signext %a, i32 %b) nounwind {
1005 ; RV64I-LABEL: zext_srlw_sext_aext:
1007 ; RV64I-NEXT: srlw a0, a0, a1
1008 ; RV64I-NEXT: slli a0, a0, 32
1009 ; RV64I-NEXT: srli a0, a0, 32
1011 %1 = lshr i32 %a, %b
1015 define zeroext i32 @zext_srlw_sext_sext(i32 signext %a, i32 signext %b) nounwind {
1016 ; RV64I-LABEL: zext_srlw_sext_sext:
1018 ; RV64I-NEXT: srlw a0, a0, a1
1019 ; RV64I-NEXT: slli a0, a0, 32
1020 ; RV64I-NEXT: srli a0, a0, 32
1022 %1 = lshr i32 %a, %b
1026 define zeroext i32 @zext_srlw_sext_zext(i32 signext %a, i32 zeroext %b) nounwind {
1027 ; RV64I-LABEL: zext_srlw_sext_zext:
1029 ; RV64I-NEXT: srlw a0, a0, a1
1030 ; RV64I-NEXT: slli a0, a0, 32
1031 ; RV64I-NEXT: srli a0, a0, 32
1033 %1 = lshr i32 %a, %b
1037 define zeroext i32 @zext_srlw_zext_aext(i32 zeroext %a, i32 %b) nounwind {
1038 ; RV64I-LABEL: zext_srlw_zext_aext:
1040 ; RV64I-NEXT: srlw a0, a0, a1
1041 ; RV64I-NEXT: slli a0, a0, 32
1042 ; RV64I-NEXT: srli a0, a0, 32
1044 %1 = lshr i32 %a, %b
1048 define zeroext i32 @zext_srlw_zext_sext(i32 zeroext %a, i32 signext %b) nounwind {
1049 ; RV64I-LABEL: zext_srlw_zext_sext:
1051 ; RV64I-NEXT: srlw a0, a0, a1
1052 ; RV64I-NEXT: slli a0, a0, 32
1053 ; RV64I-NEXT: srli a0, a0, 32
1055 %1 = lshr i32 %a, %b
1059 define zeroext i32 @zext_srlw_zext_zext(i32 zeroext %a, i32 zeroext %b) nounwind {
1060 ; RV64I-LABEL: zext_srlw_zext_zext:
1062 ; RV64I-NEXT: srlw a0, a0, a1
1063 ; RV64I-NEXT: slli a0, a0, 32
1064 ; RV64I-NEXT: srli a0, a0, 32
1066 %1 = lshr i32 %a, %b
1070 define i32 @aext_sraw_aext_aext(i32 %a, i32 %b) nounwind {
1071 ; RV64I-LABEL: aext_sraw_aext_aext:
1073 ; RV64I-NEXT: sraw a0, a0, a1
1075 %1 = ashr i32 %a, %b
1079 define i32 @aext_sraw_aext_sext(i32 %a, i32 signext %b) nounwind {
1080 ; RV64I-LABEL: aext_sraw_aext_sext:
1082 ; RV64I-NEXT: sraw a0, a0, a1
1084 %1 = ashr i32 %a, %b
1088 define i32 @aext_sraw_aext_zext(i32 %a, i32 zeroext %b) nounwind {
1089 ; RV64I-LABEL: aext_sraw_aext_zext:
1091 ; RV64I-NEXT: sraw a0, a0, a1
1093 %1 = ashr i32 %a, %b
1097 define i32 @aext_sraw_sext_aext(i32 signext %a, i32 %b) nounwind {
1098 ; RV64I-LABEL: aext_sraw_sext_aext:
1100 ; RV64I-NEXT: sraw a0, a0, a1
1102 %1 = ashr i32 %a, %b
1106 define i32 @aext_sraw_sext_sext(i32 signext %a, i32 signext %b) nounwind {
1107 ; RV64I-LABEL: aext_sraw_sext_sext:
1109 ; RV64I-NEXT: sraw a0, a0, a1
1111 %1 = ashr i32 %a, %b
1115 define i32 @aext_sraw_sext_zext(i32 signext %a, i32 zeroext %b) nounwind {
1116 ; RV64I-LABEL: aext_sraw_sext_zext:
1118 ; RV64I-NEXT: sraw a0, a0, a1
1120 %1 = ashr i32 %a, %b
1124 define i32 @aext_sraw_zext_aext(i32 zeroext %a, i32 %b) nounwind {
1125 ; RV64I-LABEL: aext_sraw_zext_aext:
1127 ; RV64I-NEXT: sraw a0, a0, a1
1129 %1 = ashr i32 %a, %b
1133 define i32 @aext_sraw_zext_sext(i32 zeroext %a, i32 signext %b) nounwind {
1134 ; RV64I-LABEL: aext_sraw_zext_sext:
1136 ; RV64I-NEXT: sraw a0, a0, a1
1138 %1 = ashr i32 %a, %b
1142 define i32 @aext_sraw_zext_zext(i32 zeroext %a, i32 zeroext %b) nounwind {
1143 ; RV64I-LABEL: aext_sraw_zext_zext:
1145 ; RV64I-NEXT: sraw a0, a0, a1
1147 %1 = ashr i32 %a, %b
1151 define signext i32 @sext_sraw_aext_aext(i32 %a, i32 %b) nounwind {
1152 ; RV64I-LABEL: sext_sraw_aext_aext:
1154 ; RV64I-NEXT: sraw a0, a0, a1
1156 %1 = ashr i32 %a, %b
1160 define signext i32 @sext_sraw_aext_sext(i32 %a, i32 signext %b) nounwind {
1161 ; RV64I-LABEL: sext_sraw_aext_sext:
1163 ; RV64I-NEXT: sraw a0, a0, a1
1165 %1 = ashr i32 %a, %b
1169 define signext i32 @sext_sraw_aext_zext(i32 %a, i32 zeroext %b) nounwind {
1170 ; RV64I-LABEL: sext_sraw_aext_zext:
1172 ; RV64I-NEXT: sraw a0, a0, a1
1174 %1 = ashr i32 %a, %b
1178 define signext i32 @sext_sraw_sext_aext(i32 signext %a, i32 %b) nounwind {
1179 ; RV64I-LABEL: sext_sraw_sext_aext:
1181 ; RV64I-NEXT: sraw a0, a0, a1
1183 %1 = ashr i32 %a, %b
1187 define signext i32 @sext_sraw_sext_sext(i32 signext %a, i32 signext %b) nounwind {
1188 ; RV64I-LABEL: sext_sraw_sext_sext:
1190 ; RV64I-NEXT: sraw a0, a0, a1
1192 %1 = ashr i32 %a, %b
1196 define signext i32 @sext_sraw_sext_zext(i32 signext %a, i32 zeroext %b) nounwind {
1197 ; RV64I-LABEL: sext_sraw_sext_zext:
1199 ; RV64I-NEXT: sraw a0, a0, a1
1201 %1 = ashr i32 %a, %b
1205 define signext i32 @sext_sraw_zext_aext(i32 zeroext %a, i32 %b) nounwind {
1206 ; RV64I-LABEL: sext_sraw_zext_aext:
1208 ; RV64I-NEXT: sraw a0, a0, a1
1210 %1 = ashr i32 %a, %b
1214 define signext i32 @sext_sraw_zext_sext(i32 zeroext %a, i32 signext %b) nounwind {
1215 ; RV64I-LABEL: sext_sraw_zext_sext:
1217 ; RV64I-NEXT: sraw a0, a0, a1
1219 %1 = ashr i32 %a, %b
1223 define signext i32 @sext_sraw_zext_zext(i32 zeroext %a, i32 zeroext %b) nounwind {
1224 ; RV64I-LABEL: sext_sraw_zext_zext:
1226 ; RV64I-NEXT: sraw a0, a0, a1
1228 %1 = ashr i32 %a, %b
1232 define zeroext i32 @zext_sraw_aext_aext(i32 %a, i32 %b) nounwind {
1233 ; RV64I-LABEL: zext_sraw_aext_aext:
1235 ; RV64I-NEXT: sraw a0, a0, a1
1236 ; RV64I-NEXT: slli a0, a0, 32
1237 ; RV64I-NEXT: srli a0, a0, 32
1239 %1 = ashr i32 %a, %b
1243 define zeroext i32 @zext_sraw_aext_sext(i32 %a, i32 signext %b) nounwind {
1244 ; RV64I-LABEL: zext_sraw_aext_sext:
1246 ; RV64I-NEXT: sraw a0, a0, a1
1247 ; RV64I-NEXT: slli a0, a0, 32
1248 ; RV64I-NEXT: srli a0, a0, 32
1250 %1 = ashr i32 %a, %b
1254 define zeroext i32 @zext_sraw_aext_zext(i32 %a, i32 zeroext %b) nounwind {
1255 ; RV64I-LABEL: zext_sraw_aext_zext:
1257 ; RV64I-NEXT: sraw a0, a0, a1
1258 ; RV64I-NEXT: slli a0, a0, 32
1259 ; RV64I-NEXT: srli a0, a0, 32
1261 %1 = ashr i32 %a, %b
1265 define zeroext i32 @zext_sraw_sext_aext(i32 signext %a, i32 %b) nounwind {
1266 ; RV64I-LABEL: zext_sraw_sext_aext:
1268 ; RV64I-NEXT: sraw a0, a0, a1
1269 ; RV64I-NEXT: slli a0, a0, 32
1270 ; RV64I-NEXT: srli a0, a0, 32
1272 %1 = ashr i32 %a, %b
1276 define zeroext i32 @zext_sraw_sext_sext(i32 signext %a, i32 signext %b) nounwind {
1277 ; RV64I-LABEL: zext_sraw_sext_sext:
1279 ; RV64I-NEXT: sraw a0, a0, a1
1280 ; RV64I-NEXT: slli a0, a0, 32
1281 ; RV64I-NEXT: srli a0, a0, 32
1283 %1 = ashr i32 %a, %b
1287 define zeroext i32 @zext_sraw_sext_zext(i32 signext %a, i32 zeroext %b) nounwind {
1288 ; RV64I-LABEL: zext_sraw_sext_zext:
1290 ; RV64I-NEXT: sraw a0, a0, a1
1291 ; RV64I-NEXT: slli a0, a0, 32
1292 ; RV64I-NEXT: srli a0, a0, 32
1294 %1 = ashr i32 %a, %b
1298 define zeroext i32 @zext_sraw_zext_aext(i32 zeroext %a, i32 %b) nounwind {
1299 ; RV64I-LABEL: zext_sraw_zext_aext:
1301 ; RV64I-NEXT: sraw a0, a0, a1
1302 ; RV64I-NEXT: slli a0, a0, 32
1303 ; RV64I-NEXT: srli a0, a0, 32
1305 %1 = ashr i32 %a, %b
1309 define zeroext i32 @zext_sraw_zext_sext(i32 zeroext %a, i32 signext %b) nounwind {
1310 ; RV64I-LABEL: zext_sraw_zext_sext:
1312 ; RV64I-NEXT: sraw a0, a0, a1
1313 ; RV64I-NEXT: slli a0, a0, 32
1314 ; RV64I-NEXT: srli a0, a0, 32
1316 %1 = ashr i32 %a, %b
1320 define zeroext i32 @zext_sraw_zext_zext(i32 zeroext %a, i32 zeroext %b) nounwind {
1321 ; RV64I-LABEL: zext_sraw_zext_zext:
1323 ; RV64I-NEXT: sraw a0, a0, a1
1324 ; RV64I-NEXT: slli a0, a0, 32
1325 ; RV64I-NEXT: srli a0, a0, 32
1327 %1 = ashr i32 %a, %b
1331 ; addiw should be selected when there is a signext result.
1333 define i32 @aext_addiw_aext(i32 %a) nounwind {
1334 ; RV64I-LABEL: aext_addiw_aext:
1336 ; RV64I-NEXT: addi a0, a0, 1
1342 define i32 @aext_addiw_sext(i32 signext %a) nounwind {
1343 ; RV64I-LABEL: aext_addiw_sext:
1345 ; RV64I-NEXT: addi a0, a0, 2
1351 define i32 @aext_addiw_zext(i32 zeroext %a) nounwind {
1352 ; RV64I-LABEL: aext_addiw_zext:
1354 ; RV64I-NEXT: addi a0, a0, 3
1360 define signext i32 @sext_addiw_aext(i32 %a) nounwind {
1361 ; RV64I-LABEL: sext_addiw_aext:
1363 ; RV64I-NEXT: addiw a0, a0, 4
1369 define signext i32 @sext_addiw_sext(i32 signext %a) nounwind {
1370 ; RV64I-LABEL: sext_addiw_sext:
1372 ; RV64I-NEXT: addiw a0, a0, 5
1378 define signext i32 @sext_addiw_zext(i32 zeroext %a) nounwind {
1379 ; RV64I-LABEL: sext_addiw_zext:
1381 ; RV64I-NEXT: addiw a0, a0, 6
1387 define zeroext i32 @zext_addiw_aext(i32 %a) nounwind {
1388 ; RV64I-LABEL: zext_addiw_aext:
1390 ; RV64I-NEXT: addi a0, a0, 7
1391 ; RV64I-NEXT: slli a0, a0, 32
1392 ; RV64I-NEXT: srli a0, a0, 32
1398 define zeroext i32 @zext_addiw_sext(i32 signext %a) nounwind {
1399 ; RV64I-LABEL: zext_addiw_sext:
1401 ; RV64I-NEXT: addi a0, a0, 8
1402 ; RV64I-NEXT: slli a0, a0, 32
1403 ; RV64I-NEXT: srli a0, a0, 32
1409 define zeroext i32 @zext_addiw_zext(i32 zeroext %a) nounwind {
1410 ; RV64I-LABEL: zext_addiw_zext:
1412 ; RV64I-NEXT: addi a0, a0, 9
1413 ; RV64I-NEXT: slli a0, a0, 32
1414 ; RV64I-NEXT: srli a0, a0, 32
1420 ; slliw should be selected whenever the return is signext.
1422 define i32 @aext_slliw_aext(i32 %a) nounwind {
1423 ; RV64I-LABEL: aext_slliw_aext:
1425 ; RV64I-NEXT: slli a0, a0, 1
1431 define i32 @aext_slliw_sext(i32 signext %a) nounwind {
1432 ; RV64I-LABEL: aext_slliw_sext:
1434 ; RV64I-NEXT: slli a0, a0, 2
1440 define i32 @aext_slliw_zext(i32 zeroext %a) nounwind {
1441 ; RV64I-LABEL: aext_slliw_zext:
1443 ; RV64I-NEXT: slli a0, a0, 3
1449 define signext i32 @sext_slliw_aext(i32 %a) nounwind {
1450 ; RV64I-LABEL: sext_slliw_aext:
1452 ; RV64I-NEXT: slliw a0, a0, 4
1458 define signext i32 @sext_slliw_sext(i32 signext %a) nounwind {
1459 ; RV64I-LABEL: sext_slliw_sext:
1461 ; RV64I-NEXT: slliw a0, a0, 5
1467 define signext i32 @sext_slliw_zext(i32 zeroext %a) nounwind {
1468 ; RV64I-LABEL: sext_slliw_zext:
1470 ; RV64I-NEXT: slliw a0, a0, 6
1476 ; TODO: the constant shifts could be combined.
1478 define zeroext i32 @zext_slliw_aext(i32 %a) nounwind {
1479 ; RV64I-LABEL: zext_slliw_aext:
1481 ; RV64I-NEXT: slli a0, a0, 7
1482 ; RV64I-NEXT: slli a0, a0, 32
1483 ; RV64I-NEXT: srli a0, a0, 32
1489 define zeroext i32 @zext_slliw_sext(i32 signext %a) nounwind {
1490 ; RV64I-LABEL: zext_slliw_sext:
1492 ; RV64I-NEXT: slli a0, a0, 8
1493 ; RV64I-NEXT: slli a0, a0, 32
1494 ; RV64I-NEXT: srli a0, a0, 32
1500 define zeroext i32 @zext_slliw_zext(i32 zeroext %a) nounwind {
1501 ; RV64I-LABEL: zext_slliw_zext:
1503 ; RV64I-NEXT: slli a0, a0, 9
1504 ; RV64I-NEXT: slli a0, a0, 32
1505 ; RV64I-NEXT: srli a0, a0, 32
1511 ; srliw should be selected unless the first operand is zeroext, when srli is
1514 define i32 @aext_srliw_aext(i32 %a) nounwind {
1515 ; RV64I-LABEL: aext_srliw_aext:
1517 ; RV64I-NEXT: srliw a0, a0, 1
1523 define i32 @aext_srliw_sext(i32 signext %a) nounwind {
1524 ; RV64I-LABEL: aext_srliw_sext:
1526 ; RV64I-NEXT: srliw a0, a0, 2
1532 define i32 @aext_srliw_zext(i32 zeroext %a) nounwind {
1533 ; RV64I-LABEL: aext_srliw_zext:
1535 ; RV64I-NEXT: srli a0, a0, 3
1541 define signext i32 @sext_srliw_aext(i32 %a) nounwind {
1542 ; RV64I-LABEL: sext_srliw_aext:
1544 ; RV64I-NEXT: srliw a0, a0, 4
1550 define signext i32 @sext_srliw_sext(i32 signext %a) nounwind {
1551 ; RV64I-LABEL: sext_srliw_sext:
1553 ; RV64I-NEXT: srliw a0, a0, 5
1559 define signext i32 @sext_srliw_zext(i32 zeroext %a) nounwind {
1560 ; RV64I-LABEL: sext_srliw_zext:
1562 ; RV64I-NEXT: srli a0, a0, 6
1568 define zeroext i32 @zext_srliw_aext(i32 %a) nounwind {
1569 ; RV64I-LABEL: zext_srliw_aext:
1571 ; RV64I-NEXT: srliw a0, a0, 7
1577 define zeroext i32 @zext_srliw_sext(i32 signext %a) nounwind {
1578 ; RV64I-LABEL: zext_srliw_sext:
1580 ; RV64I-NEXT: srliw a0, a0, 8
1586 define zeroext i32 @zext_srliw_zext(i32 zeroext %a) nounwind {
1587 ; RV64I-LABEL: zext_srliw_zext:
1589 ; RV64I-NEXT: srli a0, a0, 9
1595 ; srai is equivalent to sraiw if the first operand is sign-extended.
1597 define i32 @aext_sraiw_aext(i32 %a) nounwind {
1598 ; RV64I-LABEL: aext_sraiw_aext:
1600 ; RV64I-NEXT: sraiw a0, a0, 1
1606 define i32 @aext_sraiw_sext(i32 signext %a) nounwind {
1607 ; RV64I-LABEL: aext_sraiw_sext:
1609 ; RV64I-NEXT: srai a0, a0, 2
1615 define i32 @aext_sraiw_zext(i32 zeroext %a) nounwind {
1616 ; RV64I-LABEL: aext_sraiw_zext:
1618 ; RV64I-NEXT: sraiw a0, a0, 3
1624 define signext i32 @sext_sraiw_aext(i32 %a) nounwind {
1625 ; RV64I-LABEL: sext_sraiw_aext:
1627 ; RV64I-NEXT: sraiw a0, a0, 4
1633 define signext i32 @sext_sraiw_sext(i32 signext %a) nounwind {
1634 ; RV64I-LABEL: sext_sraiw_sext:
1636 ; RV64I-NEXT: srai a0, a0, 5
1642 define signext i32 @sext_sraiw_zext(i32 zeroext %a) nounwind {
1643 ; RV64I-LABEL: sext_sraiw_zext:
1645 ; RV64I-NEXT: sraiw a0, a0, 6
1651 ; TODO: sraiw could be selected rather than sext.w and srli. Alternatively,
1652 ; the srli could be merged in to the shifts used for zero-extension.
1654 define zeroext i32 @zext_sraiw_aext(i32 %a) nounwind {
1655 ; RV64I-LABEL: zext_sraiw_aext:
1657 ; RV64I-NEXT: sext.w a0, a0
1658 ; RV64I-NEXT: srli a0, a0, 7
1659 ; RV64I-NEXT: slli a0, a0, 32
1660 ; RV64I-NEXT: srli a0, a0, 32
1666 define zeroext i32 @zext_sraiw_sext(i32 signext %a) nounwind {
1667 ; RV64I-LABEL: zext_sraiw_sext:
1669 ; RV64I-NEXT: srli a0, a0, 8
1670 ; RV64I-NEXT: slli a0, a0, 32
1671 ; RV64I-NEXT: srli a0, a0, 32
1677 ; TODO: sraiw could be selected rather than sext.w and srli. Alternatively,
1678 ; the srli could be merged in to the shifts used for zero-extension.
1680 define zeroext i32 @zext_sraiw_zext(i32 zeroext %a) nounwind {
1681 ; RV64I-LABEL: zext_sraiw_zext:
1683 ; RV64I-NEXT: sext.w a0, a0
1684 ; RV64I-NEXT: srli a0, a0, 9
1685 ; RV64I-NEXT: slli a0, a0, 32
1686 ; RV64I-NEXT: srli a0, a0, 32