[llvm] r372350 - [AMDGPU] fixed underflow in getOccupancyWithNumVGPRs

Stanislav Mekhanoshin via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 13:09:04 PDT 2019


Author: rampitec
Date: Thu Sep 19 13:09:04 2019
New Revision: 372350

URL: http://llvm.org/viewvc/llvm-project?rev=372350&view=rev
Log:
[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

Modified:
    llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.cpp

Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.cpp?rev=372350&r1=372349&r2=372350&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.cpp Thu Sep 19 13:09:04 2019
@@ -599,7 +599,7 @@ unsigned GCNSubtarget::getOccupancyWithN
   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 {




More information about the llvm-commits mailing list