[llvm] [AMDGPU] Make SGPR occupancy the exact inverse of getMaxNumSGPRs (PR #201342)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 3 08:18:04 PDT 2026
================
@@ -1361,13 +1383,24 @@ unsigned getMaxNumSGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU,
return Addressable ? AddressableNumSGPRs : 108;
if (Version.Major >= 8 && !Addressable)
AddressableNumSGPRs = 112;
- unsigned MaxNumSGPRs = getTotalNumSGPRs(STI) / WavesPerEU;
- if (STI.getFeatureBits().test(FeatureTrapHandler))
- MaxNumSGPRs -= std::min(MaxNumSGPRs, (unsigned)TRAP_NUM_SGPRS);
- MaxNumSGPRs = alignDown(MaxNumSGPRs, getSGPRAllocGranule(STI));
+ unsigned MaxNumSGPRs = getSGPRBudgetPerWave(getTotalNumSGPRs(STI), WavesPerEU,
+ getSGPRTrapHandlerReserve(STI),
+ getSGPRAllocGranule(STI));
return std::min(MaxNumSGPRs, AddressableNumSGPRs);
}
+bool isSGPROccupancyLimited(const MCSubtargetInfo &STI) {
+ // Whether the SGPR file is a limiting resource for occupancy. This is a
+ // target capability rather than a generation per se, but it currently has a
+ // single determinant: from GFX10 on, the SGPR file is large enough that the
+ // SGPR count never reduces occupancy. The test lives here, next to the SGPR
+ // model that already keys on the ISA version
+ // (getMaxNumSGPRs/getAddressableNumSGPRs), so there is one place to update --
+ // or to back by a subtarget feature -- if a future target reintroduces an
+ // SGPR-limited regime.
----------------
shiltian wrote:
By this speed, we are going to have more comments than the code. Can you trim them down?
https://github.com/llvm/llvm-project/pull/201342
More information about the llvm-commits
mailing list