[llvm] [AMDGPU] Make SGPR occupancy the exact inverse of getMaxNumSGPRs (PR #201342)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 4 01:43:17 PDT 2026
michaelselehov wrote:
> @michaelselehov the function `getSGPRBudgetPerWave` describes itself as a single source of truth shared by `getMinNumSGPRs()` / `getMaxNumSGPRs()` and "the occupancy inverse" which I assume means `getOccupancyWithNumSGPRs`, but `getOccupancyWithNumSGPRs` never seems to call `getSGPRBudgetPerWave`.
>
> I think that either the code is incorrect or the comment is confusingly worded.
Good catch, and it's the comment that's wrong, not the code. It was accurate when the inverse was a search loop calling `getSGPRBudgetPerWave`; when I switched that to the closed form (https://github.com/llvm/llvm-project/pull/201342#discussion_r3348547106) it stopped calling the helper and I left the old wording. The closed form is the exact algebraic inverse of the same per-wave budget, so I reworded the comment: `getSGPRBudgetPerWave` is shared by `getMinNumSGPRs()`/`getMaxNumSGPRs()`, and `getOccupancyWithNumSGPRs()` is the closed-form inverse of that same budget (it doesn't call the helper).
https://github.com/llvm/llvm-project/pull/201342
More information about the llvm-commits
mailing list