AMDGPU: Handle frame index expansion with no free SGPRs pre gfx9
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 4 Sep 2019 17:12:57 +0000 (17:12 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 4 Sep 2019 17:12:57 +0000 (17:12 +0000)
commit84489b34f6f147b4de6127441f3051e0d0e08364
treecadb66b916c27d26472ae6c527052ca5bc3a9b4b
parente6b26f2f91a3b80d6ee726ee1b6147d72252cc55
AMDGPU: Handle frame index expansion with no free SGPRs pre gfx9

Since an add instruction must produce an unused carry out, this
requires additional SGPRs. This can be avoided by keeping the entire
offset computation in SGPRs. If one SGPR is still available, this only
costs one extra mov. If none are available, the entire computation can
be done in place and reversed.

This does assume the use is a VGPR operand. This was already assumed,
and we currently only select frame indexes to VALU instructions. This
should probably be fixed at some point to handle more possible MIR.

llvm-svn: 370929
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
llvm/test/CodeGen/AMDGPU/pei-scavenge-sgpr-carry-out.mir [new file with mode: 0644]