[llvm] [RISCV] Don't add Zilsd pairing hints if part of the pair is reserved. (PR #169538)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 25 09:55:35 PST 2025
https://github.com/topperc created https://github.com/llvm/llvm-project/pull/169538
None
>From 15f58d2489f09971cad4ddaf4f3d7bae6e854f12 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Tue, 25 Nov 2025 09:54:43 -0800
Subject: [PATCH] [RISCV] Don't add Zilsd pairing hints if part of the pair is
reserved.
---
llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
index 263d6a1fc2220..a5aef4bea46ab 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
@@ -895,11 +895,9 @@ bool RISCVRegisterInfo::getRegAllocationHints(
// Check if this register matches the even/odd requirement
bool IsOdd = (RegNum % 2 != 0);
- // Verify the pair register exists and is in the same register class
- // TODO: Skip unallocatable registers: we need to prevent any of odd/even
- // to be reserved, so if we need odd, we need to check if corresponding
- // even is preserved, vice versa.
- if ((WantOdd && IsOdd) || (!WantOdd && !IsOdd))
+ // Don't provide hints that are paired to a reserved register.
+ MCRegister Paired = PhysReg + (IsOdd ? -1 : 1);
+ if (WantOdd == IsOdd && !MRI->isReserved(Paired))
Hints.push_back(PhysReg);
}
}
More information about the llvm-commits
mailing list