AMDGPU: Handle waitcnt overflow
authorAustin Kerbow <Austin.Kerbow@amd.com>
Sat, 2 Nov 2019 21:48:40 +0000 (14:48 -0700)
committerAustin Kerbow <Austin.Kerbow@amd.com>
Sat, 23 Nov 2019 17:34:23 +0000 (09:34 -0800)
commitfef69706dc7828c3c662533054f136de6a7bdd98
treedc2de29da61e7da4cd884d30ce9e1c7311a98fdd
parent854e956219e78cb8d7ef3b021d7be6b5d6b6af04
AMDGPU: Handle waitcnt overflow

Summary:
The waitcnt pass can overflow the counters when the number of outstanding events
for a type exceed the capacity of the counter. This can lead to inefficient
insertion of waitcnts, or to waitcnt instructions with max values for each type.
The last situation can cause an instruction which when disassembled appears to
be an illegal waitcnt without an operand.

In these cases we should add a wait for the 'counter maximum' - 1, and update the
waitcnt brackets accordingly.

Reviewers: rampitec, arsenm

Reviewed By: rampitec

Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D70418
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
llvm/test/CodeGen/AMDGPU/waitcnt-overflow.mir [new file with mode: 0644]