[AMDGPU] fixed underflow in getOccupancyWithNumVGPRs

The function could return zero if an extreme number or
registers were used. Minimal possible occupancy is 1.

Differential Revision: https://reviews.llvm.org/D67771

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372350 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Stanislav Mekhanoshin 2019-09-19 20:09:04 +00:00
parent 72bcb2596e
commit a36690edb4

View File

@ -599,7 +599,7 @@ unsigned GCNSubtarget::getOccupancyWithNumVGPRs(unsigned VGPRs) const {
if (VGPRs < Granule)
return MaxWaves;
unsigned RoundedRegs = ((VGPRs + Granule - 1) / Granule) * Granule;
return std::min(getTotalNumVGPRs() / RoundedRegs, MaxWaves);
return std::min(std::max(getTotalNumVGPRs() / RoundedRegs, 1u), MaxWaves);
}
unsigned GCNSubtarget::getReservedNumSGPRs(const MachineFunction &MF) const {