This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] fixed underflow in getOccupancyWithNumVGPRs
ClosedPublic

Authored by rampitec on Sep 19 2019, 12:18 PM.

Details

Summary

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

Diff Detail

Event Timeline

rampitec created this revision.Sep 19 2019, 12:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 19 2019, 12:18 PM

Testcase?

Bug is trivial and testcase must be huge to hit this condition. You need to have thousands of spills for this.

Testcase?

Bug is trivial and testcase must be huge to hit this condition. You need to have thousands of spills for this.

I don't see how the number of spills factors in, only the number of used VGPRs

Testcase?

Bug is trivial and testcase must be huge to hit this condition. You need to have thousands of spills for this.

I don't see how the number of spills factors in, only the number of used VGPRs

It happens in the scheduler. These are still virtual registers and there are no spills yet.

arsenm accepted this revision.Sep 19 2019, 12:57 PM
arsenm added inline comments.
llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
602

(Could also do getTotalNumVGPRs() + RoundedRegs - 1) / RoundedRegs

This revision is now accepted and ready to land.Sep 19 2019, 12:57 PM
This revision was automatically updated to reflect the committed changes.