-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AMDGPU] Account for existing SDWA selections #123221
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
frederik-h
merged 48 commits into
llvm:main
from
frederik-h:SIPeepholeSDWA-CombineSelections
Mar 3, 2025
Merged
Changes from 11 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
b29c0f2
[AMDGPU] Account for existing SDWA selections
jrbyrnes 8d16c1c
[AMDGPU] Correct transformation and simplify combineSdwaSel
frederik-h 20e23b6
[AMDGPU] Change formatting of combineSdwaSel
frederik-h 663b94c
[AMDGPU] Remove dead branch from SIPeepholeSDWA::convertToSDWA
frederik-h c2dfca0
[AMDGPU] Extract SDWA instruction creation from convertToSDWA
frederik-h 38bd038
[AMDGPU] Unify loops in SIPeepholeSDWA::convertToSDWA
frederik-h e5923ac
[AMDGPU] Invert if statement in SIPeepholeSDWA::convertToSDWA
frederik-h 7034d2d
[AMDGPU] Rename "Combine" to "CombineSelections" in SIPeepholeSDWA
frederik-h bbe9ab8
[AMDGPU] Change combineSdwaSel to use optional return type
frederik-h 245c93b
[AMDGPU] Add regression test for invalid SDWA selection handling
frederik-h 5b51aeb
[AMDGPU] clang-format changes to SIPeepholeSDWA
frederik-h b1ead11
Merge remote-tracking branch 'upstream/main' into SIPeepholeSDWA-Comb…
frederik-h aa1d42e
Merge remote-tracking branch 'upstream/main' into SIPeepholeSDWA-Comb…
frederik-h b05facb
[AMDGPU] SIPeepholeSDWA: Reenable existing SDWA instruction handling
frederik-h c3868a5
[AMDGPU] SIPeepholeSDWA: Stop using CombineSelections in convertToSDWA
frederik-h c58493c
[AMDGPU] SIPeepholeSDWA.cpp: Simplify combineSdwaSel uses
frederik-h 3242677
[AMDGPU] SIPeepholeSDWA: Change arg names and comments
frederik-h b5aa73d
[AMDGPU] Use default check prefix in sdwa-peephole-instr-combine-sel.mir
frederik-h ed16fbd
Revert unintended reformatting
frederik-h 258fb14
[AMDGPU] SIPeepholeSDWA: Verify compatibility of selections earlier
frederik-h ac0a133
[AMDGPU] SIPeepholeSDWA: Adjust comments and variable names
frederik-h a9e38fa
[AMDGPU] SIPeepholeSDWA: Add comment answering a review question
frederik-h db7f674
clang-format changes
frederik-h ac80b86
Use consistent/more specific return type for SDWA{Src,Dst}Operand fac…
frederik-h bbe87ff
fixup! Use consistent/more specific return type for SDWA{Src,Dst}Oper…
frederik-h 179007c
Merge "compatibleSelections" function back into "combineSdwaSel"
frederik-h a5a45aa
Add comprehensive test for source selection combinations
frederik-h 1290369
Revert introduction of SDWA{Dst,Src}Operand::create
frederik-h 84889b5
Fix combineSdwaSel handling of Sel == OperandSel case
frederik-h 96e055b
Add new early check for combinable selections
frederik-h 0724d76
clang-format changes
frederik-h d2943ab
Move combineSdwaSel from anon namespace and make 'static'
frederik-h c6d9f87
Move all uses of "canCombineSelections" into "potentialToConvert"
frederik-h 9d41c6c
Update llvm/lib/Target/AMDGPU/SIPeepholeSDWA.cpp
frederik-h 7bc33f4
Update llvm/test/CodeGen/AMDGPU/sdwa-peephole-instr-combine-sel2.mir
frederik-h 0c4e99f
Update llvm/lib/Target/AMDGPU/SIPeepholeSDWA.cpp
frederik-h 25bc9d0
Update llvm/lib/Target/AMDGPU/SIPeepholeSDWA.cpp
frederik-h e564af8
Update llvm/lib/Target/AMDGPU/SIPeepholeSDWA.cpp
frederik-h 4d2e8e2
fixup! Update llvm/lib/Target/AMDGPU/SIPeepholeSDWA.cpp
frederik-h 2fd69e3
Extract canCombineSel helper function
frederik-h 9190655
Split canCombineSel and reuse for SDWADstOperand::canCombineSelections
frederik-h ce79a90
Fix test: Don't use physical registers, compact registers
frederik-h 1ba89df
Merge remote-tracking branch 'upstream/main' into SIPeepholeSDWA-Comb…
frederik-h 6311358
Merge remote-tracking branch 'upstream/main' into SIPeepholeSDWA-Comb…
frederik-h 1e77766
Add test for destination selection
frederik-h 80f5210
Use right type for OpNames
frederik-h 5a19bc0
clang-format changes
frederik-h 58e278f
Add dst_sel test
frederik-h 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
124 changes: 124 additions & 0 deletions
124
llvm/test/CodeGen/AMDGPU/sdwa-peephole-instr-combine-sel.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,124 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5 | ||
# RUN: llc -mtriple=amdgcn -mcpu=gfx1030 -run-pass=si-peephole-sdwa -o - %s | FileCheck -check-prefix=NOHAZARD %s | ||
|
||
--- | ||
name: sdwa_opsel_hazard | ||
body: | | ||
; NOHAZARD-LABEL: name: sdwa_opsel_hazard | ||
; NOHAZARD: bb.0: | ||
; NOHAZARD-NEXT: successors: %bb.7(0x40000000), %bb.8(0x40000000) | ||
; NOHAZARD-NEXT: liveins: $vgpr0, $sgpr4_sgpr5, $sgpr6 | ||
; NOHAZARD-NEXT: {{ $}} | ||
; NOHAZARD-NEXT: [[DEF:%[0-9]+]]:sreg_32 = IMPLICIT_DEF | ||
; NOHAZARD-NEXT: [[DEF1:%[0-9]+]]:sreg_64_xexec_xnull = IMPLICIT_DEF | ||
; NOHAZARD-NEXT: [[DEF2:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF | ||
; NOHAZARD-NEXT: [[GLOBAL_LOAD_DWORD_SADDR:%[0-9]+]]:vgpr_32 = GLOBAL_LOAD_DWORD_SADDR killed [[DEF1]], [[DEF2]], 0, 0, implicit $exec | ||
; NOHAZARD-NEXT: [[SI_IF:%[0-9]+]]:sreg_32 = SI_IF undef [[DEF]], %bb.8, implicit-def dead $exec, implicit-def dead $scc, implicit $exec | ||
; NOHAZARD-NEXT: S_BRANCH %bb.7 | ||
; NOHAZARD-NEXT: {{ $}} | ||
; NOHAZARD-NEXT: bb.1: | ||
; NOHAZARD-NEXT: successors: %bb.2(0x80000000) | ||
; NOHAZARD-NEXT: {{ $}} | ||
; NOHAZARD-NEXT: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 255, implicit $exec | ||
; NOHAZARD-NEXT: [[V_AND_B32_sdwa:%[0-9]+]]:vgpr_32 = V_AND_B32_sdwa 0, undef [[GLOBAL_LOAD_DWORD_SADDR]], 0, [[V_MOV_B32_e32_]], 0, 6, 0, 5, 6, implicit $exec | ||
; NOHAZARD-NEXT: [[V_MOV_B32_e32_1:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 2, implicit $exec | ||
; NOHAZARD-NEXT: [[V_LSHLREV_B32_sdwa:%[0-9]+]]:vgpr_32 = V_LSHLREV_B32_sdwa 0, [[V_MOV_B32_e32_1]], 0, undef [[GLOBAL_LOAD_DWORD_SADDR]], 0, 6, 0, 6, 2, implicit $exec | ||
; NOHAZARD-NEXT: {{ $}} | ||
; NOHAZARD-NEXT: bb.2: | ||
; NOHAZARD-NEXT: successors: %bb.3(0x40000000), %bb.4(0x40000000) | ||
; NOHAZARD-NEXT: {{ $}} | ||
; NOHAZARD-NEXT: [[SI_IF1:%[0-9]+]]:sreg_32 = SI_IF killed undef %9, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec | ||
; NOHAZARD-NEXT: S_BRANCH %bb.3 | ||
; NOHAZARD-NEXT: {{ $}} | ||
; NOHAZARD-NEXT: bb.3: | ||
; NOHAZARD-NEXT: successors: %bb.4(0x80000000) | ||
; NOHAZARD-NEXT: {{ $}} | ||
; NOHAZARD-NEXT: bb.4: | ||
; NOHAZARD-NEXT: successors: %bb.5(0x40000000), %bb.6(0x40000000) | ||
; NOHAZARD-NEXT: {{ $}} | ||
; NOHAZARD-NEXT: [[SI_IF2:%[0-9]+]]:sreg_32 = SI_IF killed undef [[SI_IF1]], %bb.6, implicit-def dead $exec, implicit-def dead $scc, implicit $exec | ||
; NOHAZARD-NEXT: S_BRANCH %bb.5 | ||
; NOHAZARD-NEXT: {{ $}} | ||
; NOHAZARD-NEXT: bb.5: | ||
; NOHAZARD-NEXT: successors: %bb.6(0x80000000) | ||
; NOHAZARD-NEXT: {{ $}} | ||
; NOHAZARD-NEXT: bb.6: | ||
; NOHAZARD-NEXT: successors: %bb.9(0x40000000), %bb.10(0x40000000) | ||
; NOHAZARD-NEXT: {{ $}} | ||
; NOHAZARD-NEXT: [[SI_IF3:%[0-9]+]]:sreg_32 = SI_IF undef [[DEF]], %bb.10, implicit-def dead $exec, implicit-def dead $scc, implicit $exec | ||
; NOHAZARD-NEXT: S_BRANCH %bb.9 | ||
; NOHAZARD-NEXT: {{ $}} | ||
; NOHAZARD-NEXT: bb.7: | ||
; NOHAZARD-NEXT: successors: %bb.8(0x80000000) | ||
; NOHAZARD-NEXT: {{ $}} | ||
; NOHAZARD-NEXT: bb.8: | ||
; NOHAZARD-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000) | ||
; NOHAZARD-NEXT: {{ $}} | ||
; NOHAZARD-NEXT: [[V_LSHRREV_B32_e64_:%[0-9]+]]:vgpr_32 = V_LSHRREV_B32_e64 16, undef [[GLOBAL_LOAD_DWORD_SADDR]], implicit $exec | ||
; NOHAZARD-NEXT: [[SI_IF4:%[0-9]+]]:sreg_32 = SI_IF killed undef [[SI_IF]], %bb.2, implicit-def dead $exec, implicit-def dead $scc, implicit $exec | ||
; NOHAZARD-NEXT: S_BRANCH %bb.1 | ||
; NOHAZARD-NEXT: {{ $}} | ||
; NOHAZARD-NEXT: bb.9: | ||
; NOHAZARD-NEXT: successors: %bb.10(0x80000000) | ||
; NOHAZARD-NEXT: {{ $}} | ||
; NOHAZARD-NEXT: bb.10: | ||
; NOHAZARD-NEXT: S_ENDPGM 0 | ||
bb.0: | ||
successors: %bb.7(0x40000000), %bb.8(0x40000000) | ||
liveins: $vgpr0, $sgpr4_sgpr5, $sgpr6 | ||
|
||
%0:sreg_32 = IMPLICIT_DEF | ||
%1:sreg_64_xexec_xnull = IMPLICIT_DEF | ||
%2:vgpr_32 = IMPLICIT_DEF | ||
%3:vgpr_32 = GLOBAL_LOAD_DWORD_SADDR killed %1, %2, 0, 0, implicit $exec | ||
%4:sreg_32 = SI_IF undef %0, %bb.8, implicit-def dead $exec, implicit-def dead $scc, implicit $exec | ||
S_BRANCH %bb.7 | ||
|
||
bb.1: | ||
successors: %bb.2(0x80000000) | ||
|
||
%5:vgpr_32 = V_AND_B32_e64 undef %6, 255, implicit $exec | ||
%7:vgpr_32 = V_LSHLREV_B32_e64 2, killed undef %5, implicit $exec | ||
|
||
bb.2: | ||
successors: %bb.3(0x40000000), %bb.4(0x40000000) | ||
|
||
%8:sreg_32 = SI_IF killed undef %9, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec | ||
S_BRANCH %bb.3 | ||
|
||
bb.3: | ||
successors: %bb.4(0x80000000) | ||
|
||
bb.4: | ||
successors: %bb.5(0x40000000), %bb.6(0x40000000) | ||
|
||
%10:sreg_32 = SI_IF killed undef %8, %bb.6, implicit-def dead $exec, implicit-def dead $scc, implicit $exec | ||
S_BRANCH %bb.5 | ||
|
||
bb.5: | ||
successors: %bb.6(0x80000000) | ||
|
||
bb.6: | ||
successors: %bb.9(0x40000000), %bb.10(0x40000000) | ||
|
||
%11:sreg_32 = SI_IF undef %0, %bb.10, implicit-def dead $exec, implicit-def dead $scc, implicit $exec | ||
S_BRANCH %bb.9 | ||
|
||
bb.7: | ||
successors: %bb.8(0x80000000) | ||
|
||
bb.8: | ||
successors: %bb.1(0x40000000), %bb.2(0x40000000) | ||
|
||
%6:vgpr_32 = V_LSHRREV_B32_e64 16, undef %3, implicit $exec | ||
%9:sreg_32 = SI_IF killed undef %4, %bb.2, implicit-def dead $exec, implicit-def dead $scc, implicit $exec | ||
S_BRANCH %bb.1 | ||
|
||
bb.9: | ||
successors: %bb.10(0x80000000) | ||
|
||
bb.10: | ||
S_ENDPGM 0 | ||
|
||
... | ||
frederik-h marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
frederik-h marked this conversation as resolved.
Show resolved
Hide resolved
|
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.
Uh oh!
There was an error while loading. Please reload this page.