[llvm-branch-commits] [llvm] [AMDGPU] Improve handling of TRANS f16 hazard with typed vdst (PR #244017)
Stanislav Mekhanoshin via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Nov 18 13:59:34 PST 2026
https://github.com/rampitec created https://github.com/llvm/llvm-project/pull/244017
None
>From d03c9f0520619e93689156c6044e617f47d5898e Mon Sep 17 00:00:00 2001
From: Stanislav Mekhanoshin <Stanislav.Mekhanoshin at amd.com>
Date: Wed, 18 Nov 2026 13:48:13 -0800
Subject: [PATCH] [AMDGPU] Improve handling of TRANS f16 hazard with typed vdst
---
.../lib/Target/AMDGPU/GCNHazardRecognizer.cpp | 23 +++----------------
.../hazard-partial-trans-f16-write-fake16.mir | 4 ----
2 files changed, 3 insertions(+), 24 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
index 2598e82fa41eb..37a6e442e213f 100644
--- a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
@@ -4602,24 +4602,11 @@ bool GCNHazardRecognizer::fixTransF16ToPartialVGPRWriteHazard(
unsigned Opc = I.getOpcode();
const MCInstrDesc &Desc = TII.get(Opc);
- // Note: checking vdst does not work because it is a generic
- // OPERAND_REGISTER.
- switch (
- Desc.operands()[AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::src0)]
- .OperandType) {
- case AMDGPU::OPERAND_REG_IMM_BF16:
- case AMDGPU::OPERAND_REG_IMM_FP16:
- case AMDGPU::OPERAND_REG_IMM_NOINLINE_FP16:
- case AMDGPU::OPERAND_REG_INLINE_C_BF16:
- case AMDGPU::OPERAND_REG_INLINE_C_FP16:
+ switch (Desc.operands()[0].OperandType) {
+ case AMDGPU::OPERAND_REG_BF16:
+ case AMDGPU::OPERAND_REG_FP16:
break;
default:
- // DPP instructions have VGPR-only src0 with generic OPERAND_REGISTER
- // type. The isDPP() check will catch any TRANS opcodes including f32.
- // This is suboptimal but shall only affect fake16 compilation because
- // of the Def size check below.
- if (SIInstrInfo::isDPP(I))
- break;
return NoHazardFound;
}
@@ -4636,10 +4623,6 @@ bool GCNHazardRecognizer::fixTransF16ToPartialVGPRWriteHazard(
: NoHazardFound;
}
- // Bail for any non-16 bit DPP instructions catched in true16 mode.
- if (ST.useRealTrue16Insts())
- return NoHazardFound;
-
// Fake16 case is suboptimal as it checks the whole 32-bit def overlap w/o
// analyzing OPSEL bits.
return MI->modifiesRegister(Def, nullptr) ? HazardFound : NoHazardFound;
diff --git a/llvm/test/CodeGen/AMDGPU/hazard-partial-trans-f16-write-fake16.mir b/llvm/test/CodeGen/AMDGPU/hazard-partial-trans-f16-write-fake16.mir
index 46d48b9ac9f0a..ea757f7a9a8f5 100644
--- a/llvm/test/CodeGen/AMDGPU/hazard-partial-trans-f16-write-fake16.mir
+++ b/llvm/test/CodeGen/AMDGPU/hazard-partial-trans-f16-write-fake16.mir
@@ -126,7 +126,6 @@ body: |
$vgpr1 = V_MOV_B16_fake16_e32 0, implicit $exec
...
-# FIXME: S_WAITCNT_DEPCTR is not needed for f32 case but we cannot detect it with fake32.
---
name: trans_f32_dpp_partial_def_no_hazard
tracksRegLiveness: false
@@ -135,7 +134,6 @@ body: |
; GCN-LABEL: name: trans_f32_dpp_partial_def_no_hazard
; GCN: $vgpr1 = V_SQRT_F32_dpp $vgpr1, 0, $vgpr0, 1, 15, 15, 1, implicit $mode, implicit $exec
; GCN-NEXT: V_NOP_e32 implicit $exec
- ; GCN-NEXT: S_WAITCNT_DEPCTR .VaVdst_0
; GCN-NEXT: $vgpr1 = V_MOV_B16_fake16_e32 0, implicit $exec
$vgpr1 = V_SQRT_F32_dpp $vgpr1, 0, $vgpr0, 1, 15, 15, 1, implicit $mode, implicit $exec
$vgpr1 = V_MOV_B16_fake16_e32 0, implicit $exec
@@ -154,7 +152,6 @@ body: |
$vgpr1 = V_MOV_B16_fake16_e32 0, implicit $exec
...
-# FIXME: S_WAITCNT_DEPCTR is not needed for f32 case but we cannot detect it with fake32.
---
name: trans_f32_dpp_e64_partial_def_no_hazard
tracksRegLiveness: false
@@ -163,7 +160,6 @@ body: |
; GCN-LABEL: name: trans_f32_dpp_e64_partial_def_no_hazard
; GCN: $vgpr1 = V_SQRT_F32_e64_dpp $vgpr1, 0, $vgpr0, 0, 0, 1, 15, 15, 1, implicit $mode, implicit $exec
; GCN-NEXT: V_NOP_e32 implicit $exec
- ; GCN-NEXT: S_WAITCNT_DEPCTR .VaVdst_0
; GCN-NEXT: $vgpr1 = V_MOV_B16_fake16_e32 0, implicit $exec
$vgpr1 = V_SQRT_F32_e64_dpp $vgpr1, 0, $vgpr0, 0, 0, 1, 15, 15, 1, implicit $mode, implicit $exec
$vgpr1 = V_MOV_B16_fake16_e32 0, implicit $exec
More information about the llvm-branch-commits
mailing list