[llvm] AMDGPU: Create InstrMapping from VGPR MFMA to equivalent AGPR instruction (PR #117102)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 21 08:56:38 PST 2024
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/117102
>From e319379879f8ab79d4fdbfb7fd7c081acd872826 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Wed, 20 Nov 2024 18:07:04 -0800
Subject: [PATCH] AMDGPU: Create InstrMapping from VGPR MFMA to equivalent AGPR
instruction
This provides infrastructure for a future optimization.
---
llvm/lib/Target/AMDGPU/SIInstrInfo.h | 5 +++++
llvm/lib/Target/AMDGPU/SIInstrInfo.td | 9 +++++++++
llvm/lib/Target/AMDGPU/VOP3PInstructions.td | 12 +++++++++---
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.h b/llvm/lib/Target/AMDGPU/SIInstrInfo.h
index e55418326a4bd0..960fbb7ea15ce7 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.h
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.h
@@ -1568,6 +1568,11 @@ namespace AMDGPU {
LLVM_READONLY
int getMFMAEarlyClobberOp(uint16_t Opcode);
+ /// \returns Version of an MFMA instruction which uses AGPRs for srcC and
+ /// vdst, given an \p Opcode of an MFMA which uses VGPRs for srcC/vdst.
+ LLVM_READONLY
+ int getMFMASrcCVDstAGPROp(uint16_t Opcode);
+
/// \returns v_cmpx version of a v_cmp instruction.
LLVM_READONLY
int getVCMPXOpFromVCMP(uint16_t Opcode);
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.td b/llvm/lib/Target/AMDGPU/SIInstrInfo.td
index a6496cd4a61f19..15985ee645a95b 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.td
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.td
@@ -3146,6 +3146,15 @@ def getMFMAEarlyClobberOp : InstrMapping {
let ValueCols = [["0"]];
}
+// Map from an mfma using VGPRs to one using AGPRs.
+def getMFMASrcCVDstAGPROp : InstrMapping {
+ let FilterClass = "MFMATable";
+ let RowFields = ["AGPROp"];
+ let ColFields = ["MFMAKind"];
+ let KeyCol = ["VGPR"];
+ let ValueCols = [["AGPR"]];
+}
+
// Maps an v_cmp instruction to its v_cmpx equivalent.
def getVCMPXOpFromVCMP : InstrMapping {
let FilterClass = "VCMPVCMPXTable";
diff --git a/llvm/lib/Target/AMDGPU/VOP3PInstructions.td b/llvm/lib/Target/AMDGPU/VOP3PInstructions.td
index a6ec1dba23aad2..d8f53bc50b3ef3 100644
--- a/llvm/lib/Target/AMDGPU/VOP3PInstructions.td
+++ b/llvm/lib/Target/AMDGPU/VOP3PInstructions.td
@@ -721,9 +721,14 @@ def VOPProfileMAI_F32_V4I32_V4I32_X512_VCD : VOPProfileMAI<VOP_V16F32_V4I32_V4I3
}
-class MFMATable <bit is_mac, string Name> {
+class MFMATable <bit is_mac, string Kind, string Name,
+ string AGPROpName = NAME> {
bit IsMac = is_mac;
string FMAOp = Name;
+ string AGPROp = AGPROpName;
+
+ // Does this MFMA use "AGPR" or "VGPR" for srcC/vdst
+ string MFMAKind = Kind;
}
class MFMA_F8F6F4_WithSizeTable<int A, int B, Instruction ThisVariant, Instruction F8F8Variant> {
@@ -829,12 +834,12 @@ multiclass MAIInst<string OpName, string P, SDPatternOperator node = null_frag,
let Constraints = !if(NoDstOverlap, "@earlyclobber $vdst", "") in {
def _e64 : MAIInst<OpName, !cast<VOPProfileMAI>("VOPProfileMAI_" # P),
!if(!or(NoDstOverlap, !eq(node, null_frag)), null_frag, AgprMAIFrag<node, HasAbid, Scaled>), Scaled>,
- MFMATable<0, NAME # "_e64">;
+ MFMATable<0, "AGPR", NAME # "_e64">;
let OtherPredicates = [isGFX90APlus], Mnemonic = OpName in
def _vgprcd_e64 : MAIInst<OpName # "_vgprcd", !cast<VOPProfileMAI>("VOPProfileMAI_" # P # "_VCD"),
!if(!or(NoDstOverlap, !eq(node, null_frag)), null_frag, VgprMAIFrag<node, HasAbid, Scaled>), Scaled>,
- MFMATable<0, NAME # "_vgprcd_e64">;
+ MFMATable<0, "VGPR", NAME # "_vgprcd_e64", NAME # "_e64">;
}
if NoDstOverlap then {
@@ -843,6 +848,7 @@ multiclass MAIInst<string OpName, string P, SDPatternOperator node = null_frag,
Mnemonic = OpName in {
def "_mac_e64" : MAIInst<OpName # "_mac", !cast<VOPProfileMAI>("VOPProfileMAI_" # P),
!if(!eq(node, null_frag), null_frag, AgprMAIFrag<node, HasAbid, Scaled>), Scaled>,
+ MFMATable<1, "AGPR", NAME # "_e64", NAME # "_mac_e64">;
MFMATable<1, NAME # "_e64">;
let OtherPredicates = [isGFX90APlus] in
More information about the llvm-commits
mailing list