[PATCH] D96336: [AMDGPU] Save VGPR of whole wave when spilling

Sebastian Neubauer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 25 06:07:42 PST 2021


sebastian-ne added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h:494-495
 
+  /// When spilling SGPRs, we may need a temporary stack slot to free a VGPR.
+  Optional<int> SpillSGPRTmpIndex;
+
----------------
arsenm wrote:
> sebastian-ne wrote:
> > arsenm wrote:
> > > sebastian-ne wrote:
> > > > arsenm wrote:
> > > > > Why doesn't this use the normal emergency stack slot?
> > > > How do I get the emergency stack slot?
> > > You don't get it, it just is what automatically happens when you attempt to use the scavenger and it fails to find a free register. It's possible we would need to add SGPR  spills as one of the conditions where it will be necessary
> > Thanks for the explanation. The RegScavenger won’t spill all lanes though. Also, it won’t spill if the register is dead in the currently active lanes (which we want to fix here).
> > So, I don’t think using the scavenger works, unless we can tell the RegScavenger to spill the whole wave, and lower that to spill – flip exec – spill – flip exec again.
> Even if you don't use it's mechanism, it still has the emergency slot available in the function frame you can re-use
Yes, it would be nice do re-use that, but i don’t see a way to get an emergency slot from the RegScavenger.
We could save the emergency slot in SIFrameLowering when allocating the slot, but we cannot check if it is unused when we need it to spill an SGPR. Unconditionally using it can overwrite a saved register.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96336/new/

https://reviews.llvm.org/D96336



More information about the llvm-commits mailing list