[llvm] [RISCV] Use RVVBitsPerBlock in assignRVVStackObjectOffsets and adjustReg. NFC (PR #109848)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 24 12:09:04 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-risc-v
Author: Craig Topper (topperc)
<details>
<summary>Changes</summary>
I think the 8 here represents RVVBitsPerBlock / 8.
---
Full diff: https://github.com/llvm/llvm-project/pull/109848.diff
2 Files Affected:
- (modified) llvm/lib/Target/RISCV/RISCVFrameLowering.cpp (+4-3)
- (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp (+3-3)
``````````diff
diff --git a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
index 7abd5a49a1b5fc..22824b77c37dd6 100644
--- a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
@@ -1090,11 +1090,12 @@ RISCVFrameLowering::assignRVVStackObjectOffsets(MachineFunction &MF) const {
for (int FI : ObjectsToAllocate) {
// ObjectSize in bytes.
int64_t ObjectSize = MFI.getObjectSize(FI);
- auto ObjectAlign = std::max(Align(8), MFI.getObjectAlign(FI));
+ auto ObjectAlign =
+ std::max(Align(RISCV::RVVBitsPerBlock / 8), MFI.getObjectAlign(FI));
// If the data type is the fractional vector type, reserve one vector
// register for it.
- if (ObjectSize < 8)
- ObjectSize = 8;
+ if (ObjectSize < (RISCV::RVVBitsPerBlock / 8))
+ ObjectSize = (RISCV::RVVBitsPerBlock / 8);
Offset = alignTo(Offset + ObjectSize, ObjectAlign);
MFI.setObjectOffset(FI, -Offset);
// Update the maximum alignment of the RVV stack section
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
index 701594c0fb05dc..91d539a355ac25 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
@@ -200,11 +200,11 @@ void RISCVRegisterInfo::adjustReg(MachineBasicBlock &MBB,
ScratchReg = MRI.createVirtualRegister(&RISCV::GPRRegClass);
assert(ScalableValue > 0 && "There is no need to get VLEN scaled value.");
- assert(ScalableValue % 8 == 0 &&
+ assert(ScalableValue % (RISCV::RVVBitsPerBlock / 8) == 0 &&
"Reserve the stack by the multiple of one vector size.");
- assert(isInt<32>(ScalableValue / 8) &&
+ assert(isInt<32>(ScalableValue / (RISCV::RVVBitsPerBlock / 8)) &&
"Expect the number of vector registers within 32-bits.");
- uint32_t NumOfVReg = ScalableValue / 8;
+ uint32_t NumOfVReg = ScalableValue / (RISCV::RVVBitsPerBlock / 8);
BuildMI(MBB, II, DL, TII->get(RISCV::PseudoReadVLENB), ScratchReg)
.setMIFlag(Flag);
``````````
</details>
https://github.com/llvm/llvm-project/pull/109848
More information about the llvm-commits
mailing list