[llvm] [AMDGPU] Register allocation anti-hints to reduce MFMA hazard NOPs (PR #156943)

Diana Picus via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 6 03:36:31 PDT 2025


================
@@ -860,6 +867,56 @@ class MachineRegisterInfo {
     return RegAllocHints.inBounds(VReg) ? &RegAllocHints[VReg] : nullptr;
   }
 
+  /// setRegAllocationAntiHint - Add a register allocation anti-hint for the
+  /// specified virtual register. This tells the allocator to avoid allocating
+  /// VReg to the same physical register as AntiHintVReg (or overlapping ones).
+  void setRegAllocationAntiHint(Register VReg, Register AntiHintVReg) {
+    assert(VReg.isVirtual() && "Anti-hints are only for virtual registers");
+    assert(AntiHintVReg.isVirtual() && "Anti-hint target must be virtual");
+    AntiHintRegs.grow(Register::index2VirtReg(getNumVirtRegs()));
----------------
rovka wrote:

Do you expect to have anti-hints for most virtual registers? If not, it's probably better to grow just enough to hold VReg.

https://github.com/llvm/llvm-project/pull/156943


More information about the llvm-commits mailing list