@@ -5659,24 +5659,34 @@ bool AArch64InstructionSelector::selectIndexedLoad(MachineInstr &MI,
5659
5659
Register WriteBack = Ld.getWritebackReg ();
5660
5660
Register Base = Ld.getBaseReg ();
5661
5661
Register Offset = Ld.getOffsetReg ();
5662
-
5663
- if (Ld.isPre ())
5664
- return false ; // TODO: add pre-inc support
5665
-
5666
- unsigned Opc = 0 ;
5667
- static constexpr unsigned GPROpcodes[] = {
5668
- AArch64::LDRBBpost, AArch64::LDRHHpost, AArch64::LDRWpost,
5669
- AArch64::LDRXpost};
5670
- static constexpr unsigned FPROpcodes[] = {
5671
- AArch64::LDRBpost, AArch64::LDRHpost, AArch64::LDRSpost,
5672
- AArch64::LDRDpost, AArch64::LDRQpost};
5673
-
5662
+ LLT Ty = MRI.getType (Dst);
5663
+ assert (Ty.getSizeInBits () <= 128 && " Unexpected type for indexed load" );
5674
5664
unsigned MemSize = Ld.getMMO ().getMemoryType ().getSizeInBytes ();
5675
- if (RBI.getRegBank (Dst, MRI, TRI)->getID () == AArch64::FPRRegBankID)
5676
- Opc = FPROpcodes[Log2_32 (MemSize)];
5677
- else
5678
- Opc = GPROpcodes[Log2_32 (MemSize)];
5679
5665
5666
+ unsigned Opc = 0 ;
5667
+ if (Ld.isPre ()) {
5668
+ static constexpr unsigned GPROpcodes[] = {
5669
+ AArch64::LDRBBpre, AArch64::LDRHHpre, AArch64::LDRWpre,
5670
+ AArch64::LDRXpre};
5671
+ static constexpr unsigned FPROpcodes[] = {
5672
+ AArch64::LDRBpre, AArch64::LDRHpre, AArch64::LDRSpre, AArch64::LDRDpre,
5673
+ AArch64::LDRQpre};
5674
+ if (RBI.getRegBank (Dst, MRI, TRI)->getID () == AArch64::FPRRegBankID)
5675
+ Opc = FPROpcodes[Log2_32 (MemSize)];
5676
+ else
5677
+ Opc = GPROpcodes[Log2_32 (MemSize)];
5678
+ } else {
5679
+ static constexpr unsigned GPROpcodes[] = {
5680
+ AArch64::LDRBBpost, AArch64::LDRHHpost, AArch64::LDRWpost,
5681
+ AArch64::LDRXpost};
5682
+ static constexpr unsigned FPROpcodes[] = {
5683
+ AArch64::LDRBpost, AArch64::LDRHpost, AArch64::LDRSpost,
5684
+ AArch64::LDRDpost, AArch64::LDRQpost};
5685
+ if (RBI.getRegBank (Dst, MRI, TRI)->getID () == AArch64::FPRRegBankID)
5686
+ Opc = FPROpcodes[Log2_32 (MemSize)];
5687
+ else
5688
+ Opc = GPROpcodes[Log2_32 (MemSize)];
5689
+ }
5680
5690
auto Cst = getIConstantVRegVal (Offset, MRI);
5681
5691
if (!Cst)
5682
5692
return false ; // Shouldn't happen, but just in case.
@@ -5695,23 +5705,34 @@ bool AArch64InstructionSelector::selectIndexedStore(GIndexedStore &I,
5695
5705
Register Base = I.getBaseReg ();
5696
5706
Register Offset = I.getOffsetReg ();
5697
5707
LLT ValTy = MRI.getType (Val);
5698
-
5699
- if (I.isPre ())
5700
- return false ; // TODO: add pre-inc support
5708
+ assert (ValTy.getSizeInBits () <= 128 && " Unexpected type for indexed store" );
5701
5709
5702
5710
unsigned Opc = 0 ;
5703
- static constexpr unsigned GPROpcodes[] = {
5704
- AArch64::STRBBpost, AArch64::STRHHpost, AArch64::STRWpost,
5705
- AArch64::STRXpost};
5706
- static constexpr unsigned FPROpcodes[] = {
5707
- AArch64::STRBpost, AArch64::STRHpost, AArch64::STRSpost,
5708
- AArch64::STRDpost, AArch64::STRQpost};
5709
-
5710
- assert (ValTy.getSizeInBits () <= 128 );
5711
- if (RBI.getRegBank (Val, MRI, TRI)->getID () == AArch64::FPRRegBankID)
5712
- Opc = FPROpcodes[Log2_32 (ValTy.getSizeInBytes ())];
5713
- else
5714
- Opc = GPROpcodes[Log2_32 (ValTy.getSizeInBytes ())];
5711
+ if (I.isPre ()) {
5712
+ static constexpr unsigned GPROpcodes[] = {
5713
+ AArch64::STRBBpre, AArch64::STRHHpre, AArch64::STRWpre,
5714
+ AArch64::STRXpre};
5715
+ static constexpr unsigned FPROpcodes[] = {
5716
+ AArch64::STRBpre, AArch64::STRHpre, AArch64::STRSpre, AArch64::STRDpre,
5717
+ AArch64::STRQpre};
5718
+
5719
+ if (RBI.getRegBank (Val, MRI, TRI)->getID () == AArch64::FPRRegBankID)
5720
+ Opc = FPROpcodes[Log2_32 (ValTy.getSizeInBytes ())];
5721
+ else
5722
+ Opc = GPROpcodes[Log2_32 (ValTy.getSizeInBytes ())];
5723
+ } else {
5724
+ static constexpr unsigned GPROpcodes[] = {
5725
+ AArch64::STRBBpost, AArch64::STRHHpost, AArch64::STRWpost,
5726
+ AArch64::STRXpost};
5727
+ static constexpr unsigned FPROpcodes[] = {
5728
+ AArch64::STRBpost, AArch64::STRHpost, AArch64::STRSpost,
5729
+ AArch64::STRDpost, AArch64::STRQpost};
5730
+
5731
+ if (RBI.getRegBank (Val, MRI, TRI)->getID () == AArch64::FPRRegBankID)
5732
+ Opc = FPROpcodes[Log2_32 (ValTy.getSizeInBytes ())];
5733
+ else
5734
+ Opc = GPROpcodes[Log2_32 (ValTy.getSizeInBytes ())];
5735
+ }
5715
5736
5716
5737
auto Cst = getIConstantVRegVal (Offset, MRI);
5717
5738
if (!Cst)
0 commit comments