-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[RISCV] Correct the limit of RegPresureSet GPRAll
#118473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd expect the default to handle reserved registers correctly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The generated version in my build tree looks like the following: // 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, so fix that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RegisterClassInfo has computePSetLimit, is something not using that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, please see my comment above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This API is a mess. I would expect the TRI to be an implementation detail never directly used. This effectively reimplements the same thing in 2 places There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created #118787 to fix this. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should query the reserved registers from MachineRegisterInfo instead of doing a fresh computation of the set