[llvm] [AMDGPU] Allocate AVRegClass last (PR #146606)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 10 07:54:45 PDT 2025


================
@@ -109,6 +109,23 @@ class SIRegisterClass <string n, list<ValueType> rTypes, int Align, dag rList>
   let TSFlags{2} = HasVGPR;
   let TSFlags{3} = HasAGPR;
   let TSFlags{4} = HasSGPR;
+
+  // RA will use RegisterClass AllocationPriority amongst other info (e.g. ordering in the basic block) 
+  // to decide which registers to try to assign first. Usually, this RegisterClass priority is given
+  // very high priority, if not the highest priority, when considering which VirtReg to allocate next.
+  //
+  // We have 5 bits to assign AllocationPriorities to RegisterClasses. Generally, it is beneficial to 
+  // assign more constrained RegisterClasses first. As a result, we prioritize larger register classes
+  // over smaller register classes. 
----------------
LU-JOHN wrote:

By "we prioritize larger register classes over smaller register classes", do you mean "we prioritize register classes with larger registers"?  I was confused by this sentence since AVRegs is a larger register class than ARegs or VRegs, but AVRegs has lower priority.

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


More information about the llvm-commits mailing list