[AMDGPU] Avoid SCC clobbering before S_CSELECT_B32
authorAlexander Timofeev <alexander.timofeev@amd.com>
Tue, 18 Oct 2022 13:34:49 +0000 (15:34 +0200)
committerAlexander Timofeev <alexander.timofeev@amd.com>
Tue, 22 Nov 2022 18:08:04 +0000 (19:08 +0100)
commit48ab3e75279a7a7d0221e9dc3b60c59cdf41330d
tree4e34e8f5b023ec0badb93ec2aec64ea1a8a482a1
parentcc29c06af97df4c84ce8321dfe10e2696246e238
[AMDGPU] Avoid SCC clobbering before S_CSELECT_B32

Frame lowering inserts scalar addition to compute the offset to the
stack objects.  This instructions inserted in arbitrary place and may clobber
SCC between its definition and S_CSELECT_B32 instruction.  This change
workarounds this particular code pattern. It queries the scavenger for SGPR and
if available saves SCC to it and restore its value after frame lowering code
insertion.

Reviewed By: foad

Differential Revision: https://reviews.llvm.org/D136169
llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
llvm/test/CodeGen/AMDGPU/use_restore_frame_reg.mir [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/vgpr-spill-scc-clobber.mir