[PATCH] D115401: AMDGPU: Fix clobbering SCC when expanding large offset spill pseudos

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 8 14:04:54 PST 2021


arsenm created this revision.
arsenm added reviewers: rampitec, sebastian-ne, foad, critson, scott.linder.
Herald added subscribers: kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl, qcolombet.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

If we had a large offset which required materializing in a register,
we would emit an s_add_i32, clobbering SCC. Start checking if SCC is
live, and instead use a VGPR offset. For MUBUF, we switch to using
offen. We would do this anyway in a normal load/store with a frame
index, but not for spills.

      

The same problem still exists in other contexts where we expand frame
indices.

      

The nasty edge case is when SGPRs are spilled to memory at a large
frame offset where SCC is also clobbered. This requires a second
scavenging index, and also required several patches in the scavenger
to correctly handle multiple recursive scavenge indexes.

      

An even nastier edge case we still don't support is if we don't have
any free SGPRs. If SCC is live and we don't have any free SGPRs to
save exec, we have no way of flipping exec back and forth without also
clobbering SCC.

      

Fixes: SWDEV-309419


https://reviews.llvm.org/D115401

Files:
  llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
  llvm/test/CodeGen/AMDGPU/spill-offset-calculation.ll
  llvm/test/CodeGen/AMDGPU/spill-scavenge-offset.ll
  llvm/test/CodeGen/AMDGPU/swdev309419-agpr.mir
  llvm/test/CodeGen/AMDGPU/swdev309419-sgpr-to-vmem.mir
  llvm/test/CodeGen/AMDGPU/swdev309419-unhandled.mir
  llvm/test/CodeGen/AMDGPU/swdev309419.mir



More information about the llvm-commits mailing list