[llvm] [AMDGPU] Allocate AVRegClass last (PR #146606)
Jeffrey Byrnes via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 18 11:56:44 PDT 2025
jrbyrnes wrote:
> Needs update with [d883d5f](https://github.com/llvm/llvm-project/commit/d883d5fecf8aa7db6daa0b163599d42ca00c5808), I wrote this test when I first noticed this issue
Seems like reprioritizing the AVReg class doesn't help this case. But, I'm not sure we should be expecting AV priorities to help.
Looks like we aren't doing a good job of honoring those virtreg hints -- I am seeing less copies & desired assignment if we do something like this:
```
diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp
index fa384b296f2e..43354e042c57 100644
--- a/llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -550,8 +550,11 @@ MCRegister RAGreedy::tryAssign(const LiveInterval &VirtReg,
// If we missed a simple hint, try to cheaply evict interference from the
// preferred register.
if (Register Hint = MRI->getSimpleHint(VirtReg.reg()))
- if (Order.isHint(Hint)) {
- MCRegister PhysHint = Hint.asMCReg();
+ if (Order.isHint(Hint) || (Hint.isVirtual() && VRM->hasPhys(Hint) &&
+ Order.isHint(VRM->getPhys(Hint)))) {
+
+ MCRegister PhysHint =
+ Hint.isPhysical() ? Hint.asMCReg() : VRM->getPhys(Hint);
LLVM_DEBUG(dbgs() << "missed hint " << printReg(PhysHint, TRI) << '\n');
if (EvictAdvisor->canEvictHintInterference(VirtReg, PhysHint,
```
If we wanted to get this without the hints, I think we would probably want to constrain the %av to %agpr and maybe teach machine-cp how to handle this.
https://github.com/llvm/llvm-project/pull/146606
More information about the llvm-commits
mailing list