[PATCH] D125102: [RegAllocGreedy] New hook regClassPriorityTrumpsGlobalness

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 24 04:05:17 PDT 2022


foad added inline comments.


================
Comment at: llvm/lib/CodeGen/RegAllocGreedy.cpp:311-315
     bool ReverseLocal = TRI->reverseLocalAssignment();
     const TargetRegisterClass &RC = *MRI->getRegClass(Reg);
     bool ForceGlobal = !ReverseLocal &&
       (Size / SlotIndex::InstrDist) > (2 * RCI.getNumAllocatableRegs(&RC));
+    unsigned GlobalBit = 0;
----------------
arsenm wrote:
> I wonder if instead of adding yet another control if the heuristic here just needs to be redone.
> 
> I think there are several issues with this heuristic. First, getNumAllocatableRegs should probably return a count for disjoint registers. This number is way too big with overlapping tuples in the same register class.
> 
> Second. the use of the interval size doesn't really work if any pass modified the live intervals. I've struggled to reduce many testcases where the scheduler triggering renumbering of SlotIndexes resulted in different regalloc behavior vs. if the SlotIndexes aren't preserved (i.e. you're just using -run-pass for the one allocator pass).
getNumAllocatableRegs - sounds reasonable.

SlotIndexes - I've wondered before about forcibly renumbering them before regalloc runs to avoid this kind of problem.


================
Comment at: llvm/lib/CodeGen/RegAllocGreedy.cpp:2710
+          ? GreedyRegClassPriorityTrumpsGlobalness
+          : TRI->regClassPriorityTrumpsGlobalness(*MF);
 
----------------
arsenm wrote:
> Why a function level decision, and not a register class?
I'm not sure it makes sense to directly compare two different priorities if they might have been calculated with different settings of RegClassPriorityTrumpsGlobalness, since it is completely changing the calculation.

I was specifically interested in tuples like vreg_64 vs vreg_128, which are different classes but they overlap so you need to be able to compare their priorities.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125102/new/

https://reviews.llvm.org/D125102



More information about the llvm-commits mailing list