[PATCH] D67771: [AMDGPU] fixed underflow in getOccupancyWithNumVGPRs

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 12:18:15 PDT 2019


rampitec created this revision.
rampitec added reviewers: kzhuravl, msearles.
Herald added subscribers: hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, wdng, jvesely, arsenm.
Herald added a project: LLVM.

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


https://reviews.llvm.org/D67771

Files:
  llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp


Index: llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
@@ -599,7 +599,7 @@
   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 {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67771.220893.patch
Type: text/x-patch
Size: 575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190919/d435449b/attachment.bin>


More information about the llvm-commits mailing list