[llvm] 9ac3a85 - [AMDGPU] Disentangle MFMA handling in convertToThreeAddress. NFC.
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 1 09:00:52 PST 2022
Author: Jay Foad
Date: 2022-03-01T16:56:56Z
New Revision: 9ac3a8504736dc1dbe249a31ebbaa0f861e576eb
URL: https://github.com/llvm/llvm-project/commit/9ac3a8504736dc1dbe249a31ebbaa0f861e576eb
DIFF: https://github.com/llvm/llvm-project/commit/9ac3a8504736dc1dbe249a31ebbaa0f861e576eb.diff
LOG: [AMDGPU] Disentangle MFMA handling in convertToThreeAddress. NFC.
Move MFMA handling to the top of convertToThreeAddress and pull
IsF16 calculation out of the switch. I think this makes it clearer
exactly which mac/fmac opcodes are handled, since they are now
listed in the switch with minimal extra clutter.
Differential Revision: https://reviews.llvm.org/D120703
Added:
Modified:
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index dd69fd321f5f7..726b7fe8addf7 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -3226,32 +3226,41 @@ static void updateLiveVariables(LiveVariables *LV, MachineInstr &MI,
MachineInstr *SIInstrInfo::convertToThreeAddress(MachineInstr &MI,
LiveVariables *LV,
LiveIntervals *LIS) const {
+ MachineBasicBlock &MBB = *MI.getParent();
unsigned Opc = MI.getOpcode();
- bool IsF16 = false;
+
+ // Handle MFMA.
+ int NewMFMAOpc = AMDGPU::getMFMAEarlyClobberOp(Opc);
+ if (NewMFMAOpc != -1) {
+ MachineInstrBuilder MIB =
+ BuildMI(MBB, MI, MI.getDebugLoc(), get(NewMFMAOpc));
+ for (unsigned I = 0, E = MI.getNumOperands(); I != E; ++I)
+ MIB.add(MI.getOperand(I));
+ updateLiveVariables(LV, MI, *MIB);
+ if (LIS)
+ LIS->ReplaceMachineInstrInMaps(MI, *MIB);
+ return MIB;
+ }
+
+ // Handle MAC/FMAC.
+ bool IsF16 = Opc == AMDGPU::V_MAC_F16_e32 || Opc == AMDGPU::V_MAC_F16_e64 ||
+ Opc == AMDGPU::V_FMAC_F16_e32 || Opc == AMDGPU::V_FMAC_F16_e64;
bool IsFMA = Opc == AMDGPU::V_FMAC_F32_e32 || Opc == AMDGPU::V_FMAC_F32_e64 ||
Opc == AMDGPU::V_FMAC_F16_e32 || Opc == AMDGPU::V_FMAC_F16_e64 ||
Opc == AMDGPU::V_FMAC_F64_e32 || Opc == AMDGPU::V_FMAC_F64_e64;
bool IsF64 = Opc == AMDGPU::V_FMAC_F64_e32 || Opc == AMDGPU::V_FMAC_F64_e64;
- int NewMFMAOpc = -1;
switch (Opc) {
default:
- NewMFMAOpc = AMDGPU::getMFMAEarlyClobberOp(Opc);
- if (NewMFMAOpc == -1)
- return nullptr;
- break;
+ return nullptr;
case AMDGPU::V_MAC_F16_e64:
case AMDGPU::V_FMAC_F16_e64:
- IsF16 = true;
- LLVM_FALLTHROUGH;
case AMDGPU::V_MAC_F32_e64:
case AMDGPU::V_FMAC_F32_e64:
case AMDGPU::V_FMAC_F64_e64:
break;
case AMDGPU::V_MAC_F16_e32:
case AMDGPU::V_FMAC_F16_e32:
- IsF16 = true;
- LLVM_FALLTHROUGH;
case AMDGPU::V_MAC_F32_e32:
case AMDGPU::V_FMAC_F32_e32:
case AMDGPU::V_FMAC_F64_e32: {
@@ -3269,18 +3278,6 @@ MachineInstr *SIInstrInfo::convertToThreeAddress(MachineInstr &MI,
}
MachineInstrBuilder MIB;
- MachineBasicBlock &MBB = *MI.getParent();
-
- if (NewMFMAOpc != -1) {
- MIB = BuildMI(MBB, MI, MI.getDebugLoc(), get(NewMFMAOpc));
- for (unsigned I = 0, E = MI.getNumOperands(); I != E; ++I)
- MIB.add(MI.getOperand(I));
- updateLiveVariables(LV, MI, *MIB);
- if (LIS)
- LIS->ReplaceMachineInstrInMaps(MI, *MIB);
- return MIB;
- }
-
const MachineOperand *Dst = getNamedOperand(MI, AMDGPU::OpName::vdst);
const MachineOperand *Src0 = getNamedOperand(MI, AMDGPU::OpName::src0);
const MachineOperand *Src0Mods =
More information about the llvm-commits
mailing list