Skip to content

Commit ce8e869

Browse files
authored
[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.
1 parent d59730d commit ce8e869

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,8 +741,11 @@ bool RISCVRegisterInfo::getRegAllocationHints(
741741
bool NeedGPRC) -> void {
742742
Register Reg = MO.getReg();
743743
Register PhysReg = Reg.isPhysical() ? Reg : Register(VRM->getPhys(Reg));
744-
if (PhysReg && (!NeedGPRC || RISCV::GPRCRegClass.contains(PhysReg))) {
745-
assert(!MO.getSubReg() && !VRRegMO.getSubReg() && "Unexpected subreg!");
744+
// TODO: Support GPRPair subregisters? Need to be careful with even/odd
745+
// registers. If the virtual register is an odd register of a pair and the
746+
// physical register is even (or vice versa), we should not add the hint.
747+
if (PhysReg && (!NeedGPRC || RISCV::GPRCRegClass.contains(PhysReg)) &&
748+
!MO.getSubReg() && !VRRegMO.getSubReg()) {
746749
if (!MRI->isReserved(PhysReg) && !is_contained(Hints, PhysReg))
747750
TwoAddrHints.insert(PhysReg);
748751
}

0 commit comments

Comments
 (0)