This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Free reserved VGPR if no SGPR spill
ClosedPublic

Authored by ruiling on Mar 10 2021, 6:21 AM.

Details

Summary

I met some code generation behavior change when I tried to remove
the hasStackObject() check when reserving VGPR for SGPR spill.
For example, the function callee_no_stack_no_fp_elim_all in the lit
test file callee-frame-setup.ll.
The generated code changed from:

s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
s_mov_b32 s4, s33
s_mov_b32 s33, s32
s_mov_b32 s33, s4
s_setpc_b64 s[30:31]

into something like:

s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
v_writelane_b32 v63, s33, 0
s_mov_b32 s33, s32
v_readlane_b32 s33, v63, 0
s_setpc_b64 s[30:31]

I think we still prefer the old version where only scalar instructions are needed.
The idea here is free the reserved VGPR if no SGPR spills. So we will very likely
to use a free SGPR for fp/sp spill.

Diff Detail

Event Timeline

ruiling created this revision.Mar 10 2021, 6:21 AM
ruiling requested review of this revision.Mar 10 2021, 6:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 10 2021, 6:21 AM
arsenm accepted this revision.Mar 10 2021, 4:26 PM
This revision is now accepted and ready to land.Mar 10 2021, 4:26 PM
This revision was automatically updated to reflect the committed changes.