aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
diff options
context:
space:
mode:
authorDavid Green <david.green@arm.com>2021-07-26 14:26:38 +0100
committerDavid Green <david.green@arm.com>2021-07-26 14:26:38 +0100
commit010f8e305705acb5128f409256e7f22ff3adc780 (patch)
treec6ba283bf95f551907c39ac4e163e5e65c45a1d9 /llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
parenta487a49acc5a172909d706ffc43240ced1ac0693 (diff)
downloadllvm-010f8e305705acb5128f409256e7f22ff3adc780.zip
llvm-010f8e305705acb5128f409256e7f22ff3adc780.tar.gz
llvm-010f8e305705acb5128f409256e7f22ff3adc780.tar.bz2
[ARM] Ensure correct regclass in distributing postinc
The register class required for some MVE loads/stores is more constrained than the register we use when creating postinc. Make sure we constrain the register class to keep the code correct.
Diffstat (limited to 'llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp')
-rw-r--r--llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
index 28fe01c..fd06bfd 100644
--- a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
+++ b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
@@ -2726,9 +2726,18 @@ static bool isLegalOrConvertableAddressImm(unsigned Opcode, int Imm,
// by -Offset. This can either happen in-place or be a replacement as MI is
// converted to another instruction type.
static void AdjustBaseAndOffset(MachineInstr *MI, Register NewBaseReg,
- int Offset, const TargetInstrInfo *TII) {
+ int Offset, const TargetInstrInfo *TII,
+ const TargetRegisterInfo *TRI) {
+ // Set the Base reg
unsigned BaseOp = getBaseOperandIndex(*MI);
MI->getOperand(BaseOp).setReg(NewBaseReg);
+ // and constrain the reg class to that required by the instruction.
+ MachineFunction *MF = MI->getMF();
+ MachineRegisterInfo &MRI = MF->getRegInfo();
+ const MCInstrDesc &MCID = TII->get(MI->getOpcode());
+ const TargetRegisterClass *TRC = TII->getRegClass(MCID, BaseOp, TRI, *MF);
+ MRI.constrainRegClass(NewBaseReg, TRC);
+
int OldOffset = MI->getOperand(BaseOp + 1).getImm();
if (isLegalAddressImm(MI->getOpcode(), OldOffset - Offset, TII))
MI->getOperand(BaseOp + 1).setImm(OldOffset - Offset);
@@ -2971,7 +2980,7 @@ bool ARMPreAllocLoadStoreOpt::DistributeIncrements(Register Base) {
for (auto *Use : SuccessorAccesses) {
LLVM_DEBUG(dbgs() << "Changing: "; Use->dump());
- AdjustBaseAndOffset(Use, NewBaseReg, IncrementOffset, TII);
+ AdjustBaseAndOffset(Use, NewBaseReg, IncrementOffset, TII, TRI);
LLVM_DEBUG(dbgs() << " To : "; Use->dump());
}