Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ bool RISCVRegisterInfo::getRegAllocationHints(
unsigned HintType = Hint.first;
Register Partner = Hint.second;

MCRegister TargetReg;
if (HintType == RISCVRI::RegPairEven || HintType == RISCVRI::RegPairOdd) {
// Check if we want the even or odd register of a consecutive pair
bool WantOdd = (HintType == RISCVRI::RegPairOdd);
Expand All @@ -877,7 +878,7 @@ bool RISCVRegisterInfo::getRegAllocationHints(
if (Partner.isVirtual() && VRM && VRM->hasPhys(Partner)) {
MCRegister PartnerPhys = VRM->getPhys(Partner);
// Calculate the exact register we need for consecutive pairing
MCRegister TargetReg = PartnerPhys.id() + (WantOdd ? 1 : -1);
TargetReg = PartnerPhys.id() + (WantOdd ? 1 : -1);

// Verify it's valid and available
if (RISCV::GPRRegClass.contains(TargetReg) &&
Expand All @@ -888,7 +889,8 @@ bool RISCVRegisterInfo::getRegAllocationHints(
// Second priority: Try to find consecutive register pairs in the allocation
// order
for (MCPhysReg PhysReg : Order) {
if (!PhysReg)
// Don't add the hint if we already added above.
if (TargetReg == PhysReg)
continue;

unsigned RegNum = getEncodingValue(PhysReg);
Expand Down