-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[AMDGPU] Prohibit load/store merge if scale_offset is set on gfx1250 #149895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rampitec
merged 3 commits into
main
from
users/rampitec/07-21-_amdgpu_prohibit_load_store_merge_if_scale_offset_is_set_on_gfx1250
Jul 21, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2 | ||
| # RUN: llc -mtriple=amdgcn -mcpu=gfx1250 -start-before=si-fold-operands -stop-after=prologepilog -o - %s | FileCheck -check-prefix=GCN %s | ||
|
|
||
| --- | ||
| name: test_fold_fi_scratch_load_vgpr | ||
| tracksRegLiveness: true | ||
| machineFunctionInfo: | ||
| scratchRSrcReg: $sgpr0_sgpr1_sgpr2_sgpr3 | ||
| stackPtrOffsetReg: $sgpr32 | ||
| stack: | ||
| - { id: 0, name: '', type: spill-slot, offset: 0, size: 4, alignment: 4 } | ||
| body: | | ||
| bb.0.entry: | ||
| ; GCN-LABEL: name: test_fold_fi_scratch_load_vgpr | ||
| ; GCN: renamable $vgpr0 = SCRATCH_LOAD_DWORD_SADDR $sgpr32, 4, 0, implicit $exec, implicit $flat_scr :: (load (s32) from %stack.0, addrspace 5) | ||
| ; GCN-NEXT: S_ENDPGM 0, implicit killed renamable $vgpr0 | ||
| %0:vgpr_32 = V_MOV_B32_e32 %stack.0, implicit $exec | ||
| %1:vgpr_32 = SCRATCH_LOAD_DWORD %0:vgpr_32, 4, 0, implicit $exec, implicit $flat_scr :: (load 4 from %stack.0, addrspace 5) | ||
| S_ENDPGM 0, implicit %1 | ||
|
|
||
| ... | ||
|
|
||
| # SS form of the SCRATCH_LOAD_DWORD does not support offset scaling | ||
|
|
||
| --- | ||
| name: test_no_fold_fi_scratch_load_vgpr_scale_offset | ||
| tracksRegLiveness: true | ||
| machineFunctionInfo: | ||
| scratchRSrcReg: $sgpr0_sgpr1_sgpr2_sgpr3 | ||
| stackPtrOffsetReg: $sgpr32 | ||
| stack: | ||
| - { id: 0, name: '', type: spill-slot, offset: 0, size: 4, alignment: 4 } | ||
| body: | | ||
| bb.0.entry: | ||
| ; GCN-LABEL: name: test_no_fold_fi_scratch_load_vgpr_scale_offset | ||
| ; GCN: renamable $vgpr0 = V_MOV_B32_e32 $sgpr32, implicit $exec | ||
| ; GCN-NEXT: renamable $vgpr0 = SCRATCH_LOAD_DWORD killed renamable $vgpr0, 4, 2048, implicit $exec, implicit $flat_scr :: (load (s32) from %stack.0, addrspace 5) | ||
| ; GCN-NEXT: S_ENDPGM 0, implicit killed renamable $vgpr0 | ||
| %0:vgpr_32 = V_MOV_B32_e32 %stack.0, implicit $exec | ||
| %1:vgpr_32 = SCRATCH_LOAD_DWORD %0:vgpr_32, 4, 2048, implicit $exec, implicit $flat_scr :: (load 4 from %stack.0, addrspace 5) | ||
| S_ENDPGM 0, implicit %1 | ||
|
|
||
| ... |
104 changes: 104 additions & 0 deletions
104
llvm/test/CodeGen/AMDGPU/load-store-opt-scale-offset.mir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2 | ||
| # RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1250 -run-pass=si-load-store-opt -o - %s | FileCheck -check-prefix=GCN %s | ||
|
|
||
| --- | ||
| name: merge_global_load_dword_2_no_scale_offset | ||
| body: | | ||
| bb.0.entry: | ||
|
|
||
| ; GCN-LABEL: name: merge_global_load_dword_2_no_scale_offset | ||
| ; GCN: [[DEF:%[0-9]+]]:sreg_64_xexec_xnull = IMPLICIT_DEF | ||
| ; GCN-NEXT: [[DEF1:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF | ||
| ; GCN-NEXT: [[GLOBAL_LOAD_DWORDX2_SADDR:%[0-9]+]]:vreg_64_align2 = GLOBAL_LOAD_DWORDX2_SADDR [[DEF]], [[DEF1]], 0, 1, implicit $exec :: (load (s64) from `ptr addrspace(1) undef` + 4, align 4, addrspace 1) | ||
| ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY [[GLOBAL_LOAD_DWORDX2_SADDR]].sub0 | ||
| ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY killed [[GLOBAL_LOAD_DWORDX2_SADDR]].sub1 | ||
| ; GCN-NEXT: S_NOP 0, implicit [[DEF1]], implicit [[COPY]] | ||
| %0:sreg_64_xexec_xnull = IMPLICIT_DEF | ||
| %1:vgpr_32 = IMPLICIT_DEF | ||
| %2:vgpr_32 = GLOBAL_LOAD_DWORD_SADDR %0, %1, 0, 1, implicit $exec :: (load (s32) from `float addrspace(1)* undef` + 4, basealign 4, addrspace 1) | ||
| %3:vgpr_32 = GLOBAL_LOAD_DWORD_SADDR %0, %1, 4, 1, implicit $exec :: (load (s32) from `i32 addrspace(1)* undef` + 8, basealign 4, addrspace 1) | ||
| S_NOP 0, implicit %1, implicit %2 | ||
| ... | ||
|
|
||
| --- | ||
| name: no_merge_global_load_dword_2_same_scale_offset | ||
| body: | | ||
| bb.0.entry: | ||
|
|
||
| ; GCN-LABEL: name: no_merge_global_load_dword_2_same_scale_offset | ||
| ; GCN: [[DEF:%[0-9]+]]:sreg_64_xexec_xnull = IMPLICIT_DEF | ||
| ; GCN-NEXT: [[DEF1:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF | ||
| ; GCN-NEXT: [[GLOBAL_LOAD_DWORD_SADDR:%[0-9]+]]:vgpr_32 = GLOBAL_LOAD_DWORD_SADDR [[DEF]], [[DEF1]], 0, 2049, implicit $exec :: (load (s32) from `ptr addrspace(1) undef` + 4, addrspace 1) | ||
| ; GCN-NEXT: [[GLOBAL_LOAD_DWORD_SADDR1:%[0-9]+]]:vgpr_32 = GLOBAL_LOAD_DWORD_SADDR [[DEF]], [[DEF1]], 4, 2049, implicit $exec :: (load (s32) from `ptr addrspace(1) undef` + 8, addrspace 1) | ||
| ; GCN-NEXT: S_NOP 0, implicit [[DEF1]], implicit [[GLOBAL_LOAD_DWORD_SADDR]] | ||
| %0:sreg_64_xexec_xnull = IMPLICIT_DEF | ||
| %1:vgpr_32 = IMPLICIT_DEF | ||
| %2:vgpr_32 = GLOBAL_LOAD_DWORD_SADDR %0, %1, 0, 2049, implicit $exec :: (load (s32) from `float addrspace(1)* undef` + 4, basealign 4, addrspace 1) | ||
| %3:vgpr_32 = GLOBAL_LOAD_DWORD_SADDR %0, %1, 4, 2049, implicit $exec :: (load (s32) from `i32 addrspace(1)* undef` + 8, basealign 4, addrspace 1) | ||
| S_NOP 0, implicit %1, implicit %2 | ||
| ... | ||
|
|
||
| --- | ||
| name: no_merge_global_load_dword_2_different_scale_offset | ||
| body: | | ||
| bb.0.entry: | ||
|
|
||
| ; GCN-LABEL: name: no_merge_global_load_dword_2_different_scale_offset | ||
| ; GCN: [[DEF:%[0-9]+]]:sreg_64_xexec_xnull = IMPLICIT_DEF | ||
| ; GCN-NEXT: [[DEF1:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF | ||
| ; GCN-NEXT: [[GLOBAL_LOAD_DWORD_SADDR:%[0-9]+]]:vgpr_32 = GLOBAL_LOAD_DWORD_SADDR [[DEF]], [[DEF1]], 0, 0, implicit $exec :: (load (s32) from `ptr addrspace(1) undef` + 4, addrspace 1) | ||
| ; GCN-NEXT: [[GLOBAL_LOAD_DWORD_SADDR1:%[0-9]+]]:vgpr_32 = GLOBAL_LOAD_DWORD_SADDR [[DEF]], [[DEF1]], 4, 2048, implicit $exec :: (load (s32) from `ptr addrspace(1) undef` + 8, addrspace 1) | ||
| ; GCN-NEXT: S_NOP 0, implicit [[DEF1]], implicit [[GLOBAL_LOAD_DWORD_SADDR]] | ||
| %0:sreg_64_xexec_xnull = IMPLICIT_DEF | ||
| %1:vgpr_32 = IMPLICIT_DEF | ||
| %2:vgpr_32 = GLOBAL_LOAD_DWORD_SADDR %0, %1, 0, 0, implicit $exec :: (load (s32) from `float addrspace(1)* undef` + 4, basealign 4, addrspace 1) | ||
| %3:vgpr_32 = GLOBAL_LOAD_DWORD_SADDR %0, %1, 4, 2048, implicit $exec :: (load (s32) from `i32 addrspace(1)* undef` + 8, basealign 4, addrspace 1) | ||
| S_NOP 0, implicit %1, implicit %2 | ||
| ... | ||
|
|
||
| # NB: We do not currently support merging SGPR offset and SGPR+Imm offset forms | ||
| # of S_LOAD, but the check stays the same: these cannot be merged with different | ||
| # scale offsets. | ||
| # | ||
| # We also do not currently merge flat scratch instructions, although a common | ||
| # check in the merge logic that CPol shall not be set for merge to happen. | ||
|
|
||
| --- | ||
| name: merge_s_load_x1_x1_imm_no_scale_offset | ||
| body: | | ||
| bb.0: | ||
| ; GCN-LABEL: name: merge_s_load_x1_x1_imm_no_scale_offset | ||
| ; GCN: [[DEF:%[0-9]+]]:sgpr_64 = IMPLICIT_DEF | ||
| ; GCN-NEXT: [[S_LOAD_DWORDX2_IMM:%[0-9]+]]:sreg_64_xexec = S_LOAD_DWORDX2_IMM [[DEF]], 0, 0 :: (dereferenceable invariant load (s64), align 4) | ||
| ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_32_xm0_xexec = COPY [[S_LOAD_DWORDX2_IMM]].sub0 | ||
| ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_32_xm0_xexec = COPY killed [[S_LOAD_DWORDX2_IMM]].sub1 | ||
| %0:sgpr_64 = IMPLICIT_DEF | ||
| %1:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM %0:sgpr_64, 0, 0 :: (dereferenceable invariant load (s32)) | ||
| %2:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM %0:sgpr_64, 4, 0 :: (dereferenceable invariant load (s32)) | ||
| ... | ||
|
|
||
| --- | ||
| name: no_merge_s_load_x1_x1_imm_same_scale_offset | ||
| body: | | ||
| bb.0: | ||
| ; GCN-LABEL: name: no_merge_s_load_x1_x1_imm_same_scale_offset | ||
| ; GCN: [[DEF:%[0-9]+]]:sgpr_64 = IMPLICIT_DEF | ||
| ; GCN-NEXT: [[S_LOAD_DWORD_IMM:%[0-9]+]]:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM [[DEF]], 0, 2048 :: (dereferenceable invariant load (s32)) | ||
| ; GCN-NEXT: [[S_LOAD_DWORD_IMM1:%[0-9]+]]:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM [[DEF]], 4, 2048 :: (dereferenceable invariant load (s32)) | ||
| %0:sgpr_64 = IMPLICIT_DEF | ||
| %1:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM %0:sgpr_64, 0, 2048 :: (dereferenceable invariant load (s32)) | ||
| %2:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM %0:sgpr_64, 4, 2048 :: (dereferenceable invariant load (s32)) | ||
| ... | ||
|
|
||
| --- | ||
| name: no_merge_s_load_x1_x1_imm_different_scale_offset | ||
| body: | | ||
| bb.0: | ||
| ; GCN-LABEL: name: no_merge_s_load_x1_x1_imm_different_scale_offset | ||
| ; GCN: [[DEF:%[0-9]+]]:sgpr_64 = IMPLICIT_DEF | ||
| ; GCN-NEXT: [[S_LOAD_DWORD_IMM:%[0-9]+]]:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM [[DEF]], 0, 0 :: (dereferenceable invariant load (s32)) | ||
| ; GCN-NEXT: [[S_LOAD_DWORD_IMM1:%[0-9]+]]:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM [[DEF]], 4, 2048 :: (dereferenceable invariant load (s32)) | ||
| %0:sgpr_64 = IMPLICIT_DEF | ||
| %1:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM %0:sgpr_64, 0, 0 :: (dereferenceable invariant load (s32)) | ||
| %2:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM %0:sgpr_64, 4, 2048 :: (dereferenceable invariant load (s32)) | ||
| ... |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I'd make several groups here and then leave blank lines to prevent clang-format from complaining about it but it's completely up to you.