llvm.org GIT mirror llvm / ec5cc76
[ARM GlobalISel] Widen small shift operands The legalizer was already widening the shift amount. Add tests for that behaviour, and also support widening the shifted value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359542 91177308-0d34-0410-b5e6-96231b3b80d8 Diana Picus 8 months ago
2 changed file(s) with 122 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
8989
9090 getActionDefinitionsBuilder({G_ASHR, G_LSHR, G_SHL})
9191 .legalFor({{s32, s32}})
92 .minScalar(0, s32)
9293 .clampScalar(1, s32, s32);
9394
9495 bool HasHWDivide = (!ST.isThumb() && ST.hasDivideInARMMode()) ||
2727 define void @test_lshr_s32() { ret void }
2828 define void @test_ashr_s32() { ret void }
2929 define void @test_shl_s32() { ret void }
30
31 define void @test_shift_s8() { ret void }
32 define void @test_shift_s16() { ret void }
33 define void @test_shift_amount_s8() { ret void }
34 define void @test_shift_amount_s16() { ret void }
3035 ...
3136 ---
3237 name: test_add_s8
637642 BX_RET 14, $noreg, implicit $r0
638643
639644 ...
645 ---
646 name: test_shift_s8
647 # CHECK-LABEL: name: test_shift_s8
648 legalized: false
649 # CHECK: legalized: true
650 regBankSelected: false
651 selected: false
652 tracksRegLiveness: true
653 registers:
654 - { id: 0, class: _ }
655 - { id: 1, class: _ }
656 - { id: 2, class: _ }
657 - { id: 3, class: _ }
658 - { id: 4, class: _ }
659 body: |
660 bb.0:
661 liveins: $r0, $r1
662
663 %0(s32) = COPY $r0
664 %1(s32) = COPY $r1
665 %2(s8) = G_TRUNC %0(s32)
666 %3(s8) = G_SHL %2, %1(s32)
667 ; G_SHL with s8 should widen
668 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_SHL {{%[0-9]+, %[0-9]+}}
669 ; CHECK: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}
670 ; CHECK-NOT: {{%[0-9]+}}:_(s8) = G_SHL {{%[0-9]+, %[0-9]+}}
671 %4(s32) = G_SEXT %3(s8)
672 $r0 = COPY %4(s32)
673 BX_RET 14, $noreg, implicit $r0
674 ...
675 ---
676 name: test_shift_s16
677 # CHECK-LABEL: name: test_shift_s16
678 legalized: false
679 # CHECK: legalized: true
680 regBankSelected: false
681 selected: false
682 tracksRegLiveness: true
683 registers:
684 - { id: 0, class: _ }
685 - { id: 1, class: _ }
686 - { id: 2, class: _ }
687 - { id: 3, class: _ }
688 - { id: 4, class: _ }
689 body: |
690 bb.0:
691 liveins: $r0, $r1
692
693 %0(s32) = COPY $r0
694 %1(s32) = COPY $r1
695 %2(s16) = G_TRUNC %0(s32)
696 %3(s16) = G_SHL %2, %1(s32)
697 ; G_SHL with s16 should widen
698 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_SHL {{%[0-9]+, %[0-9]+}}
699 ; CHECK: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}
700 ; CHECK-NOT: {{%[0-9]+}}:_(s16) = G_SHL {{%[0-9]+, %[0-9]+}}
701 %4(s32) = G_SEXT %3(s16)
702 $r0 = COPY %4(s32)
703 BX_RET 14, $noreg, implicit $r0
704 ...
705 ---
706 name: test_shift_amount_s8
707 # CHECK-LABEL: name: test_shift_amount_s8
708 legalized: false
709 # CHECK: legalized: true
710 regBankSelected: false
711 selected: false
712 tracksRegLiveness: true
713 registers:
714 - { id: 0, class: _ }
715 - { id: 1, class: _ }
716 - { id: 2, class: _ }
717 - { id: 3, class: _ }
718 body: |
719 bb.0:
720 liveins: $r0, $r1
721
722 %0(s32) = COPY $r0
723 %1(s32) = COPY $r1
724 %2(s8) = G_TRUNC %0(s32)
725 %3(s32) = G_SHL %1, %2(s8)
726 ; G_SHL with s8 amount should widen
727 ; CHECK-NOT: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}(s8)
728 ; CHECK: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}(s32)
729 ; CHECK-NOT: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}(s8)
730 $r0 = COPY %3(s32)
731 BX_RET 14, $noreg, implicit $r0
732 ...
733 ---
734 name: test_shift_amount_s16
735 # CHECK-LABEL: name: test_shift_amount_s16
736 legalized: false
737 # CHECK: legalized: true
738 regBankSelected: false
739 selected: false
740 tracksRegLiveness: true
741 registers:
742 - { id: 0, class: _ }
743 - { id: 1, class: _ }
744 - { id: 2, class: _ }
745 - { id: 3, class: _ }
746 body: |
747 bb.0:
748 liveins: $r0, $r1
749
750 %0(s32) = COPY $r0
751 %1(s32) = COPY $r1
752 %2(s16) = G_TRUNC %0(s32)
753 %3(s32) = G_SHL %1, %2(s16)
754 ; G_SHL with s16 amount should widen
755 ; CHECK-NOT: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}(s16)
756 ; CHECK: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}(s32)
757 ; CHECK-NOT: {{%[0-9]+}}:_(s32) = G_SHL {{%[0-9]+, %[0-9]+}}(s16)
758 $r0 = COPY %3(s32)
759 BX_RET 14, $noreg, implicit $r0
760 ...