[PATCH] D153279: [AMDGPU] Reimplement the GFX11 early release VGPRs optimization

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 19 07:54:43 PDT 2023


foad added inline comments.


================
Comment at: llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.global.atomic.csub.ll:162
 ; GFX11-NEXT:    global_atomic_csub_u32 v0, v1, v0, s[0:1] glc
-; GFX11-NEXT:    s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
 ; GFX11-NEXT:    s_endpgm
----------------
`global_atomic_csub_u32 ... glc` is an atomic-with-return which uses VMcnt. The hardware will wait until VMcnt==0 before sending the MSG_DEALLOC_VGPRS message, so there is no point sending it.


================
Comment at: llvm/test/CodeGen/AMDGPU/call-argument-types.ll:4385
 ; GFX11-NEXT:    s_swappc_b64 s[30:31], s[2:3]
-; GFX11-NEXT:    s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
 ; GFX11-NEXT:    s_endpgm
----------------
`s_swappc_b64` is a call. The ABI says that the callee should wait for memory counters like VScnt to be 0 before returning, so there should be no outstanding stores at this point.


================
Comment at: llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.buffer.load.ll:594
 ; GFX11-NEXT:    exp mrt0 v0, v0, v0, v0 done
+; GFX11-NEXT:    s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
 ; GFX11-NEXT:    s_endpgm
----------------
The old AMDGPUReleaseVGPRs pass did not send the message here because the `global_store_b32` above was not the last VGPR-using instruction before the `s_endpgm`. I don't understand why it was implemented that way. I think we do want to send the message, because VScnt might be non-zero here.


================
Comment at: llvm/test/CodeGen/AMDGPU/waitcnt-preexisting-vscnt.mir:34
     ; GFX11-NEXT: FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
+    ; GFX11-NEXT: S_SENDMSG 3, implicit $exec, implicit $m0
     ; GFX11-NEXT: S_ENDPGM 0
----------------
This is only different because we insert these instructions during the SIInsertWaitcnts pass, instead of in a separate pass.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153279



More information about the llvm-commits mailing list