[llvm] [RISCV] Correct the limit of RegPresureSet `GPRAll` (PR #118473)
Sam Elliott via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 3 06:13:44 PST 2024
================
@@ -934,3 +934,17 @@ bool RISCVRegisterInfo::getRegAllocationHints(
return BaseImplRetVal;
}
+
+unsigned RISCVRegisterInfo::getRegPressureSetLimit(const MachineFunction &MF,
+ unsigned Idx) const {
+ if (Idx == RISCV::RegisterPressureSets::GPRAll) {
+ unsigned Reserved = 0;
+ BitVector ReservedRegs = getReservedRegs(MF);
+ for (MCPhysReg Reg = RISCV::X0_H; Reg <= RISCV::X31_H; Reg++)
+ if (ReservedRegs.test(Reg))
+ Reserved++;
+
+ return 32 - Reserved;
+ }
+ return RISCVGenRegisterInfo::getRegPressureSetLimit(MF, Idx);
----------------
lenary wrote:
The generated version in my build tree looks like the following:
```cpp
// Get the register unit pressure limit for this dimension.
// This limit must be adjusted dynamically for reserved registers.
unsigned RISCVGenRegisterInfo::
getRegPressureSetLimit(const MachineFunction &MF, unsigned Idx) const {
static const uint8_t PressureLimitTable[] = {
2, // 0: GPRC_and_SR07
2, // 1: GPRX0
2, // 2: SP
2, // 3: GPRX7
3, // 4: GPRX1
8, // 5: FPR16C
8, // 6: GPRF16C
8, // 7: SR07
8, // 8: VMV0
14, // 9: GPRF16C_with_SR07
16, // 10: GPRTC
24, // 11: VRM8NoV0
32, // 12: FPR16
32, // 13: VM
33, // 14: GPRAll
};
return PressureLimitTable[Idx];
}
```
So it is not correctly handling dynamically reserved registers.
https://github.com/llvm/llvm-project/pull/118473
More information about the llvm-commits
mailing list