Skip to content

Commit 4e7c65e

Browse files
authored
[RISCV] Don't add duplicate Zilsd hints. (#169554)
This matches what ARM does. I'm not sure if there are any bad effects from the duplicate hints. I have seen the duplicates hints in the debug output and confirmed this removes them.
1 parent 76ec25f commit 4e7c65e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,7 @@ bool RISCVRegisterInfo::getRegAllocationHints(
869869
unsigned HintType = Hint.first;
870870
Register Partner = Hint.second;
871871

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

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

894896
unsigned RegNum = getEncodingValue(PhysReg);

0 commit comments

Comments
 (0)