[llvm] [RISC-V] Only emit multiples of 16 as immediate for cm.push (PR #84935)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 12 15:34:03 PDT 2024


================
@@ -555,9 +555,9 @@ void RISCVFrameLowering::emitPrologue(MachineFunction &MF,
       FirstFrameSetup->getOpcode() == RISCV::CM_PUSH) {
     // Use available stack adjustment in push instruction to allocate additional
     // stack space.
-    uint64_t Spimm = std::min(StackSize, (uint64_t)48);
+    uint64_t Spimm = alignTo(std::min(StackSize, (uint64_t)48), 16);
     FirstFrameSetup->getOperand(1).setImm(Spimm);
-    StackSize -= Spimm;
+    StackSize -= std::min(StackSize, Spimm);
----------------
topperc wrote:

Does this mean we can move the sp by more than StackSize? Doesn't that make the position of sp out of sync with the rest of the code?

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


More information about the llvm-commits mailing list