[PATCH] D98802: [RISCV][WIP] Fix offset computation for RVV

luxufan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 18 22:45:54 PDT 2021


StephenFan added a comment.

In D98802#2634791 <https://reviews.llvm.org/D98802#2634791>, @StephenFan wrote:

> Hi @rogfer01 ! It is reasonable to me. But I think the instruction of `BuildMI(MBB, MBBI, DL, TII->get(RISCV::ADDI), SPReg)` can be eliminated. Firstly, the value of calleeSavedStackSize can be regarded as a aligned value(For example, aligned to MFI.getStackAlign()). Then we can calculate the padding size by the aligned calleeSavedStackSize minus the original calleeSavedStackSize. When emits prologue, we can minus the value of  `MFI.getStackSize() - original calleeSavedStackSize + aligned calleeSavedStackSize`. When get the offset of the rvv object, we can `MFI.getStackSize() - original calleesavedStackSize`, because we just want to calculate the 
> non-calleesaved field size. My English is poor and I am a beginner of LLVM-RISCV.  So I don't know if it makes sense to you.





================
Comment at: llvm/lib/Target/RISCV/RISCVFrameLowering.cpp:882
+  if (RVVStackSize && !hasFP(MF) && Size % 8 != 0) {
+    RVFI->setRVVPadding(getStackAlign().value());
+  }
----------------
If we can set the RVVPadding as 
```
RVFI->setRVVPadding(alignTo(Size, getStackAlign().value()) -Size);
```
or just align to 8, because we just want the RVV stack aligned to 8 bytes.
```
RVFI->setRVVPadding(alignTo(Size, 8) - Size);
```
?
In this way, maybe we can save some stack space.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98802/new/

https://reviews.llvm.org/D98802



More information about the llvm-commits mailing list