[llvm] [AMDGPU] Make SGPR occupancy the exact inverse of getMaxNumSGPRs (PR #201342)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 4 08:18:52 PDT 2026
michaelselehov wrote:
### Update: SGPR occupancy round-trip unit test
Added `TestSGPRLimitsPerOccupancy` (`AMDGPUUnitTests.cpp`), the SGPR mirror of the
existing `TestVGPRLimitsPerOccupancy`: for every AMDGCN target it checks that
`getOccupancyWithNumSGPRs` round-trips with `getMinNumSGPRs`/`getMaxNumSGPRs` --
i.e. that the occupancy query really is the inverse of the SGPR budget this PR
unifies. The shared `checkMinMax` helper gains an `AllowUnreachable` flag: SGPRs
are coarse enough that some occupancy levels are physically unrealizable (no SGPR
count yields them), which is a legitimate gap rather than a min/max
inconsistency; the VGPR test keeps the strict (default) behavior.
This doubles as a regression test for the core fix. Retrofitted onto the pre-PR
base the new test fails -- the old table returns occupancies that disagree with
the budget (e.g. 81 SGPRs -> 9 waves on gfx9 where granule rounding gives 8, and
0 SGPRs -> 10 waves on the 8-wave gfx90a) -- and it passes with this PR.
https://github.com/llvm/llvm-project/pull/201342
More information about the llvm-commits
mailing list