[llvm] [CodeGen] Avoid register pressure limit underflow (PR #216372)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 17 12:48:28 PDT 2026


================
@@ -213,7 +213,10 @@ unsigned RegisterClassInfo::computePSetLimit(unsigned Idx) const {
   if (NAllocatableRegs == 0)
     return RegPressureSetLimit;
   unsigned NReserved = RC->getNumRegs() - NAllocatableRegs;
-  return RegPressureSetLimit - TRI->getRegClassWeight(RC).RegWeight * NReserved;
+  unsigned ReservedRegWeight = TRI->getRegClassWeight(RC).RegWeight * NReserved;
+  if (ReservedRegWeight >= RegPressureSetLimit)
+    return RegPressureSetLimit;
+  return RegPressureSetLimit - ReservedRegWeight;
----------------
hjagasiaAMD wrote:

The 2048 comes from getLargestRegClassForRegPressureSet(VGPR_32) selecting VGPR_16, which contains the low and high 16-bit halves of VGPR0–VGPR1023.

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


More information about the llvm-commits mailing list