[llvm] ce8e869 - [RISCV] Convert an assertion to an if condition in getRegAllocationHints (#85998)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 20 22:53:54 PDT 2024
Author: Craig Topper
Date: 2024-03-20T22:53:51-07:00
New Revision: ce8e86971036cb34c3d32cf0b70169379c85ae2f
URL: https://github.com/llvm/llvm-project/commit/ce8e86971036cb34c3d32cf0b70169379c85ae2f
DIFF: https://github.com/llvm/llvm-project/commit/ce8e86971036cb34c3d32cf0b70169379c85ae2f.diff
LOG: [RISCV] Convert an assertion to an if condition in getRegAllocationHints (#85998)
With GPR pairs from Zdinx, we can't guarantee there are no subregisters
on integer instruction operands. I've been able to get these assertions
to fire after some other recent PRs.
I've added a FIXME to support this properly. I just wanted to prevent
the assertion failure for now.
No test case because my other patch #85982 that allowed me to fail the assert
hasn't been approved yet, and I don't know for that that patch is
required to hit this assert. It's just what exposed it for me. So I
think this patch is a good precaution regardless.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
index 10bf1e88d74146..952d17468da590 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
@@ -741,8 +741,11 @@ bool RISCVRegisterInfo::getRegAllocationHints(
bool NeedGPRC) -> void {
Register Reg = MO.getReg();
Register PhysReg = Reg.isPhysical() ? Reg : Register(VRM->getPhys(Reg));
- if (PhysReg && (!NeedGPRC || RISCV::GPRCRegClass.contains(PhysReg))) {
- assert(!MO.getSubReg() && !VRRegMO.getSubReg() && "Unexpected subreg!");
+ // TODO: Support GPRPair subregisters? Need to be careful with even/odd
+ // registers. If the virtual register is an odd register of a pair and the
+ // physical register is even (or vice versa), we should not add the hint.
+ if (PhysReg && (!NeedGPRC || RISCV::GPRCRegClass.contains(PhysReg)) &&
+ !MO.getSubReg() && !VRRegMO.getSubReg()) {
if (!MRI->isReserved(PhysReg) && !is_contained(Hints, PhysReg))
TwoAddrHints.insert(PhysReg);
}
More information about the llvm-commits
mailing list