AMDGPU/InsertWaitcnts: Remove the dependence on MachineLoopInfo
authorNicolai Haehnle <nhaehnle@gmail.com>
Thu, 29 Nov 2018 11:06:26 +0000 (11:06 +0000)
committerNicolai Haehnle <nhaehnle@gmail.com>
Thu, 29 Nov 2018 11:06:26 +0000 (11:06 +0000)
commit7bed696915968a21122036502359f3eaea7714b3
tree0d7cc637f9a271dd9cf6dcc97ed0983b0f7911eb
parentab43bf60fec6b2067137a82483093700d0edabd2
AMDGPU/InsertWaitcnts: Remove the dependence on MachineLoopInfo

Summary:
MachineLoopInfo cannot be relied on for correctness, because it cannot
properly recognize loops in irreducible control flow which can be
introduced by late machine basic block optimization passes. See the new
test case for the reduced form of an example that occurred in practice.

Use a simple fixpoint iteration instead.

In order to facilitate this change, refactor WaitcntBrackets so that it
only tracks pending events and registers, rather than also maintaining
state that is relevant for the high-level algorithm. Various accessor
methods can be removed or made private as a consequence.

Affects (in radv):
- dEQP-VK.glsl.loops.special.{for,while}_uniform_iterations.select_iteration_count_{fragment,vertex}

Fixes: r345719 ("AMDGPU: Rewrite SILowerI1Copies to always stay on SALU")

Reviewers: msearles, rampitec, scott.linder, kanarayan

Subscribers: arsenm, kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, llvm-commits, hakzsam

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

llvm-svn: 347853
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
llvm/test/CodeGen/AMDGPU/waitcnt-loop-irreducible.mir [new file with mode: 0644]