[llvm] [AArch64]Fix invalid use of ld1/st1 in stack alloc (PR #105518)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 3 08:00:47 PDT 2024


================
@@ -3354,10 +3360,21 @@ bool AArch64FrameLowering::spillCalleeSavedRegisters(
           MachinePointerInfo::getFixedStack(MF, FrameIdxReg2),
           MachineMemOperand::MOStore, Size, Alignment));
       MIB.addReg(PnReg);
-      MIB.addReg(AArch64::SP)
-          .addImm(RPI.Offset) // [sp, #offset*scale],
-                              // where factor*scale is implicit
-          .setMIFlag(MachineInstr::FrameSetup);
+      MIB.addReg(AArch64::SP);
+      if (RPI.Offset >= -8 && RPI.Offset <= 7)
+        MIB.addImm(RPI.Offset);
+      else {
+        // When stack offset out of range for st1b scalar + imm variant,
+        // store offset in register for use in scalar + scalar variant.
+        Register ScratchReg = findScratchNonCalleeSaveRegister(&MBB);
----------------
Lukacma wrote:

I have fixed the offset issue and make it revert STR when outside of range.

https://github.com/llvm/llvm-project/pull/105518


More information about the llvm-commits mailing list