[llvm] [RISCV] Use shNadd for scalable stack offsets (PR #88062)
Fraser Cormack via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 9 07:29:42 PDT 2024
================
@@ -204,10 +204,21 @@ void RISCVRegisterInfo::adjustReg(MachineBasicBlock &MBB,
uint32_t NumOfVReg = ScalableValue / 8;
BuildMI(MBB, II, DL, TII->get(RISCV::PseudoReadVLENB), ScratchReg)
.setMIFlag(Flag);
- TII->mulImm(MF, MBB, II, DL, ScratchReg, NumOfVReg, Flag);
- BuildMI(MBB, II, DL, TII->get(ScalableAdjOpc), DestReg)
- .addReg(SrcReg).addReg(ScratchReg, RegState::Kill)
- .setMIFlag(Flag);
+
+ if (ScalableAdjOpc == RISCV::ADD && ST.hasStdExtZba() &&
+ (NumOfVReg == 2 || NumOfVReg == 4 || NumOfVReg == 8)) {
+ unsigned Opc = NumOfVReg == 2 ? RISCV::SH1ADD :
+ (NumOfVReg == 4 ? RISCV::SH2ADD : RISCV::SH3ADD);
+ BuildMI(MBB, II, DL, TII->get(Opc), DestReg)
+ .addReg(ScratchReg, RegState::Kill)
+ .addReg(SrcReg, getKillRegState(KillSrcReg))
----------------
frasercrmck wrote:
I had to do a double-take, but I meant on `SrcReg`.
https://github.com/llvm/llvm-project/pull/88062
More information about the llvm-commits
mailing list