Skip to content

AMDGPU: Handle gfx950 XDL Write-VGPR-VALU-WAW wait state change #126132

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
merged 4 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2596,12 +2596,14 @@ static int GFX940_SMFMA_N_PassWriteVgprVALUWawWaitStates(int NumPasses) {
return NumPasses + 2;
}

static int GFX940_XDL_N_PassWriteVgprVALUWawWaitStates(int NumPasses) {
// 2 pass -> 5
// 4 pass -> 7
// 8 pass -> 11
// 16 pass -> 19
return NumPasses + 3;
static int GFX940_XDL_N_PassWriteVgprVALUWawWaitStates(int NumPasses,
bool IsGFX950) {
// xdl def cycles | gfx940 | gfx950
// 2 pass | 5 5
// 4 pass | 7 8
// 8 pass | 11 12
// 16 pass | 19 20
return NumPasses + 3 + (NumPasses != 2 && IsGFX950);
}

static int GFX940_XDL_N_PassWriteVgprVALUMemExpReadWaitStates(int NumPasses) {
Expand Down Expand Up @@ -2846,7 +2848,8 @@ int GCNHazardRecognizer::checkMAIVALUHazards(MachineInstr *MI) {
} else if (ST.hasGFX940Insts()) {
NeedWaitStates =
isXDL(ST, *MFMA)
? GFX940_XDL_N_PassWriteVgprVALUWawWaitStates(NumPasses)
? GFX940_XDL_N_PassWriteVgprVALUWawWaitStates(
NumPasses, ST.hasGFX950Insts())
: GFX940_SMFMA_N_PassWriteVgprVALUWawWaitStates(NumPasses);
} else {
switch (NumPasses) {
Expand Down
30 changes: 20 additions & 10 deletions llvm/test/CodeGen/AMDGPU/mai-hazards-gfx940.mir
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,8 @@ body: |
# GCN: V_MFMA
# GCN-NEXT: S_NOP 7
# GCN-NEXT: S_NOP 7
# GCN-NEXT: S_NOP 2
# GFX940-NEXT: S_NOP 2
# GFX950-NEXT: S_NOP 3
# GCN-NEXT: V_MOV_B32
name: xdl_smfma32x32_write_vgpr_valu_read
body: |
Expand Down Expand Up @@ -946,7 +947,8 @@ body: |
# GCN-LABEL: name: xdl_smfma16x16_write_vgpr_valu_write
# GCN: V_MFMA
# GCN-NEXT: S_NOP 7
# GCN-NEXT: S_NOP 2
# GFX940-NEXT: S_NOP 2
# GFX950-NEXT: S_NOP 3
# GCN-NEXT: V_MOV_B32
name: xdl_smfma16x16_write_vgpr_valu_write
body: |
Expand All @@ -958,7 +960,8 @@ body: |
# GCN: V_MFMA
# GCN-NEXT: S_NOP 7
# GCN-NEXT: S_NOP 7
# GCN-NEXT: S_NOP 2
# GFX940-NEXT: S_NOP 2
# GFX950-NEXT: S_NOP 3
# GCN-NEXT: V_MOV_B32
name: xdl_smfma32x32_write_vgpr_valu_write
body: |
Expand All @@ -979,7 +982,8 @@ body: |
# GCN-LABEL: name: xdl_smfma16x16_write_vgpr_valu_f16_write
# GCN: V_MFMA
# GCN-NEXT: S_NOP 7
# GCN-NEXT: S_NOP 2
# GFX940-NEXT: S_NOP 2
# GFX950-NEXT: S_NOP 3
# GCN-NEXT: V_FMA_F16_e64
name: xdl_smfma16x16_write_vgpr_valu_f16_write
body: |
Expand All @@ -991,7 +995,8 @@ body: |
# GCN: V_MFMA
# GCN-NEXT: S_NOP 7
# GCN-NEXT: S_NOP 7
# GCN-NEXT: S_NOP 2
# GFX940-NEXT: S_NOP 2
# GFX950-NEXT: S_NOP 3
# GCN-NEXT: V_FMA_F16_e64
name: xdl_smfma32x32_write_vgpr_valu_f16_write
body: |
Expand All @@ -1012,7 +1017,8 @@ body: |
# GCN-LABEL: name: xdl_smfma16x16_write_vgpr_valu_sdwa_write
# GCN: V_MFMA
# GCN-NEXT: S_NOP 7
# GCN-NEXT: S_NOP 2
# GFX940-NEXT: S_NOP 2
# GFX950-NEXT: S_NOP 3
# GCN-NEXT: V_MOV_B32_sdwa
name: xdl_smfma16x16_write_vgpr_valu_sdwa_write
body: |
Expand All @@ -1024,7 +1030,8 @@ body: |
# GCN: V_MFMA
# GCN-NEXT: S_NOP 7
# GCN-NEXT: S_NOP 7
# GCN-NEXT: S_NOP 2
# GFX940-NEXT: S_NOP 2
# GFX950-NEXT: S_NOP 3
# GCN-NEXT: V_MOV_B32_sdwa
name: xdl_smfma32x32_write_vgpr_valu_sdwa_write
body: |
Expand Down Expand Up @@ -1745,7 +1752,8 @@ body: |
...
# GCN-LABEL: name: xdl_sgemm16X16X16_mfma_write_vgpr_valu_write
# GCN: V_MFMA
# GCN-NEXT: S_NOP 6
# GFX940-NEXT: S_NOP 6
# GFX950-NEXT: S_NOP 7
# GCN-NEXT: V_MOV_B32
name: xdl_sgemm16X16X16_mfma_write_vgpr_valu_write
body: |
Expand Down Expand Up @@ -2052,7 +2060,8 @@ body: |
...
# GCN-LABEL: name: smfmac16x16_read_vgpr_srcc_valu_write
# GCN: V_SMFMAC
# GCN-NEXT: S_NOP 6
# GFX940-NEXT: S_NOP 6
# GFX950-NEXT: S_NOP 7
# GCN-NEXT: V_MOV_B32
name: smfmac16x16_read_vgpr_srcc_valu_write
body: |
Expand Down Expand Up @@ -2082,7 +2091,8 @@ body: |
# GCN-LABEL: name: smfmac32x32_read_vgpr_srcc_valu_write
# GCN: V_SMFMAC
# GCN-NEXT: S_NOP 7
# GCN-NEXT: S_NOP 2
# GFX940-NEXT: S_NOP 2
# GFX950-NEXT: S_NOP 3
# GCN-NEXT: V_MOV_B32
name: smfmac32x32_read_vgpr_srcc_valu_write
body: |
Expand Down