[llvm] [AMDGPU] Include unused preload kernarg in KD total SGPR count (PR #104743)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 08:30:47 PDT 2024


================
@@ -970,8 +970,15 @@ void AMDGPUAsmPrinter::getSIProgramInfo(SIProgramInfo &ProgInfo,
     return SubGPR;
   };
 
-  ProgInfo.SGPRBlocks = GetNumGPRBlocks(ProgInfo.NumSGPRsForWavesPerEU,
-                                        IsaInfo::getSGPREncodingGranule(&STM));
+  // Consider cases where the total number of UserSGPRs plus extra SGPRs is
+  // greater than the number of explicitly referenced SGPRs.
+  const MCExpr *MaxUserSGPRs = MCBinaryExpr::createAdd(
+      CreateExpr(MFI->getNumUserSGPRs()), ExtraSGPRs, Ctx);
+
+  ProgInfo.SGPRBlocks =
+      GetNumGPRBlocks(AMDGPUMCExpr::createMax(
----------------
arsenm wrote:

I think fixing this up here is too late. We should have bumped up the SGPR count in the MFI tracked value to begin with. We have a similar round up for the unused inreg shader arguments, and this is essentially the same thing 

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


More information about the llvm-commits mailing list