]> granicus.if.org Git - llvm/commit
[AMDGPU] Allow hoisting of comparisons out of a loop and eliminate condition copies
authorStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Mon, 7 Nov 2016 23:04:50 +0000 (23:04 +0000)
committerStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Mon, 7 Nov 2016 23:04:50 +0000 (23:04 +0000)
commitc312996e7a99eae912f6c1c67b6d1bef5a84c42c
tree03bc607183802edb44e7267bddcb9ca7c81b2366
parent330e12bad4975aa3c9335ddb7223f462977484d4
[AMDGPU] Allow hoisting of comparisons out of a loop and eliminate condition copies

Codegen prepare sinks comparisons close to a user is we have only one register
for conditions. For AMDGPU we have many SGPRs capable to hold vector conditions.
Changed BE to report we have many condition registers. That way IR LICM pass
would hoist an invariant comparison out of a loop and codegen prepare will not
sink it.

With that done a condition is calculated in one block and used in another.
Current behavior is to store workitem's condition in a VGPR using v_cndmask
and then restore it with yet another v_cmp instruction from that v_cndmask's
result. To mitigate the issue a forward propagation of a v_cmp 64 bit result
to an user is implemented. Additional side effect of this is that we may
consume less VGPRs in a cost of more SGPRs in case if holding of multiple
conditions is needed, and that is a clear win in most cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286171 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/AMDGPU/AMDGPUISelLowering.cpp
lib/Target/AMDGPU/SILowerI1Copies.cpp
test/CodeGen/AMDGPU/branch-relaxation.ll
test/CodeGen/AMDGPU/host-cond.ll [new file with mode: 0644]