[AMDGPU] Fixed wait count reuse
authorStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Thu, 8 Feb 2018 00:18:35 +0000 (00:18 +0000)
committerStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Thu, 8 Feb 2018 00:18:35 +0000 (00:18 +0000)
commitdb39b4b0b46a6e6add4fa3fa9bda94fb4489a22f
treeb49a2fed3a5c0aa85d7a490fb70877d0dde5aed3
parent0be0cfa65b0197be7501efd04c49098e013c1a58
[AMDGPU] Fixed wait count reuse

The code reusing existing wait counts is incorrect since it keeps
adding new operands to an old instruction instead of replacing
the immediate. It was also effectively switched off by the condition
that wait count is not an AMDGPU::S_WAITCNT.

Also switched to BuildMI instead of creating instructions directly.

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

llvm-svn: 324547
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp