llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[AMDGPU] unspill-vgpr-after-rewrite-vgpr-mfma.ll: x2 case no longer eliminates spills

Open petar-jovanovic opened this issue 1 month ago • 4 comments

Since SlotIndexes compaction became the AMDGPU default (#235806), @eliminate_spill_after_mfma_rewrite_x2 no longer does what its comment says ("fold out 2 spills from %spill0 and %spill1"). AMDGPURewriteAGPRCopyMFMAnow eliminates no spills (2 before). The test still passes because its checks are autogenerated.

Not a miscompile: the code is better (56 spill stores instead of 80), because greedy now keeps one of the two 1024-bit tuples in registers.

Reproduce (add -greedy-compact-slot-indexes=false for the old behaviour):

llc -mtriple=amdgpu9.0a-amd-amdhsa -amdgpu-mfma-vgpr-form \
    -debug-only=amdgpu-rewrite-agpr-copy-mfma -filetype=null \
    unspill-vgpr-after-rewrite-vgpr-mfma.ll 2>&1 | grep -c '^Reassigning SS#'

petar-jovanovic avatar Oct 29 '26 14:10 petar-jovanovic

Recommendation: Update the x2 comment to describe the current behaviour. Successful elimination is still covered by the rewrite-vgpr-mfma-to-agpr-spill-multi-store tests.

petar-jovanovic avatar Oct 29 '26 14:10 petar-jovanovic

@arsenm do you agree with the proposal or would suggest something different?

petar-jovanovic avatar Oct 29 '26 14:10 petar-jovanovic

@llvm/issue-subscribers-backend-amdgpu

Author: Petar Jovanovic (petar-jovanovic)

Since SlotIndexes compaction became the AMDGPU default (#235806), `@eliminate_spill_after_mfma_rewrite_x2` no longer does what its comment says ("fold out 2 spills from %spill0 and %spill1"). `AMDGPURewriteAGPRCopyMFMA`now eliminates no spills (2 before). The test still passes because its checks are autogenerated.

Not a miscompile: the code is better (56 spill stores instead of 80), because greedy now keeps one of the two 1024-bit tuples in registers.

Reproduce (add -greedy-compact-slot-indexes=false for the old behaviour):

llc -mtriple=amdgpu9.0a-amd-amdhsa -amdgpu-mfma-vgpr-form \
    -debug-only=amdgpu-rewrite-agpr-copy-mfma -filetype=null \
    unspill-vgpr-after-rewrite-vgpr-mfma.ll 2>&1 | grep -c '^Reassigning SS#'

any comments @arsenm ?

petar-jovanovic avatar Nov 03 '26 17:11 petar-jovanovic