Skip to content

Commit d0878f1

Browse files
authored
[RISCV] Use RVVBitsPerBlock in assignRVVStackObjectOffsets and adjustReg. NFC (#109848)
I think the 8 here represents RVVBitsPerBlock / 8.
1 parent 3b8c78a commit d0878f1

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

llvm/lib/Target/RISCV/RISCVFrameLowering.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1090,11 +1090,12 @@ RISCVFrameLowering::assignRVVStackObjectOffsets(MachineFunction &MF) const {
10901090
for (int FI : ObjectsToAllocate) {
10911091
// ObjectSize in bytes.
10921092
int64_t ObjectSize = MFI.getObjectSize(FI);
1093-
auto ObjectAlign = std::max(Align(8), MFI.getObjectAlign(FI));
1093+
auto ObjectAlign =
1094+
std::max(Align(RISCV::RVVBitsPerBlock / 8), MFI.getObjectAlign(FI));
10941095
// If the data type is the fractional vector type, reserve one vector
10951096
// register for it.
1096-
if (ObjectSize < 8)
1097-
ObjectSize = 8;
1097+
if (ObjectSize < (RISCV::RVVBitsPerBlock / 8))
1098+
ObjectSize = (RISCV::RVVBitsPerBlock / 8);
10981099
Offset = alignTo(Offset + ObjectSize, ObjectAlign);
10991100
MFI.setObjectOffset(FI, -Offset);
11001101
// Update the maximum alignment of the RVV stack section

llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ void RISCVRegisterInfo::adjustReg(MachineBasicBlock &MBB,
200200
ScratchReg = MRI.createVirtualRegister(&RISCV::GPRRegClass);
201201

202202
assert(ScalableValue > 0 && "There is no need to get VLEN scaled value.");
203-
assert(ScalableValue % 8 == 0 &&
203+
assert(ScalableValue % (RISCV::RVVBitsPerBlock / 8) == 0 &&
204204
"Reserve the stack by the multiple of one vector size.");
205-
assert(isInt<32>(ScalableValue / 8) &&
205+
assert(isInt<32>(ScalableValue / (RISCV::RVVBitsPerBlock / 8)) &&
206206
"Expect the number of vector registers within 32-bits.");
207-
uint32_t NumOfVReg = ScalableValue / 8;
207+
uint32_t NumOfVReg = ScalableValue / (RISCV::RVVBitsPerBlock / 8);
208208
BuildMI(MBB, II, DL, TII->get(RISCV::PseudoReadVLENB), ScratchReg)
209209
.setMIFlag(Flag);
210210

0 commit comments

Comments
 (0)