Skip to content

Commit 61dad88

Browse files
Removed the legalization of the Opcode and used lower()
1 parent d512507 commit 61dad88

File tree

6 files changed

+8
-41
lines changed

6 files changed

+8
-41
lines changed

llvm/include/llvm/Support/TargetOpcodes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ HANDLE_TARGET_OPCODE(G_FMA)
643643

644644
/// Generic FP multiply and add. Behaves as separate fmul and fadd.
645645
HANDLE_TARGET_OPCODE(G_FMAD)
646-
HANDLE_TARGET_OPCODE(G_STRICT_FMULADD)
646+
HANDLE_TARGET_OPCODE(G_STRICT_FMAD)
647647

648648
/// Generic FP division.
649649
HANDLE_TARGET_OPCODE(G_FDIV)

llvm/include/llvm/Target/GenericOpcodes.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,7 @@ def G_STRICT_FREM : ConstrainedInstruction<G_FREM>;
17161716
def G_STRICT_FMA : ConstrainedInstruction<G_FMA>;
17171717
def G_STRICT_FSQRT : ConstrainedInstruction<G_FSQRT>;
17181718
def G_STRICT_FLDEXP : ConstrainedInstruction<G_FLDEXP>;
1719-
def G_STRICT_FMULADD : ConstrainedInstruction<G_FMAD>;
1719+
def G_STRICT_FMAD : ConstrainedInstruction<G_FMAD>;
17201720

17211721
//------------------------------------------------------------------------------
17221722
// Memory intrinsics

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2081,7 +2081,7 @@ static unsigned getConstrainedOpcode(Intrinsic::ID ID) {
20812081
case Intrinsic::experimental_constrained_ldexp:
20822082
return TargetOpcode::G_STRICT_FLDEXP;
20832083
case Intrinsic::experimental_constrained_fmuladd:
2084-
return TargetOpcode::G_STRICT_FMULADD;
2084+
return TargetOpcode::G_STRICT_FMAD;
20852085
default:
20862086
return 0;
20872087
}

llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4523,6 +4523,7 @@ LegalizerHelper::lower(MachineInstr &MI, unsigned TypeIdx, LLT LowerHintTy) {
45234523
return Legalized;
45244524
}
45254525
case TargetOpcode::G_FMAD:
4526+
case TargetOpcode::G_STRICT_FMAD:
45264527
return lowerFMad(MI);
45274528
case TargetOpcode::G_FFLOOR:
45284529
return lowerFFloor(MI);

llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,6 @@ class SPIRVInstructionSelector : public InstructionSelector {
232232
bool selectExt(Register ResVReg, const SPIRVType *ResType, MachineInstr &I,
233233
bool IsSigned) const;
234234

235-
bool selectStrictFMulAdd(Register ResVReg, const SPIRVType *ResType,
236-
MachineInstr &I) const;
237-
238235
bool selectTrunc(Register ResVReg, const SPIRVType *ResType,
239236
MachineInstr &I) const;
240237

@@ -716,9 +713,6 @@ bool SPIRVInstructionSelector::spvSelect(Register ResVReg,
716713
case TargetOpcode::G_FMA:
717714
return selectExtInst(ResVReg, ResType, I, CL::fma, GL::Fma);
718715

719-
case TargetOpcode::G_STRICT_FMULADD:
720-
return selectStrictFMulAdd(ResVReg, ResType, I);
721-
722716
case TargetOpcode::G_STRICT_FLDEXP:
723717
return selectExtInst(ResVReg, ResType, I, CL::ldexp);
724718

@@ -1068,37 +1062,6 @@ bool SPIRVInstructionSelector::selectOpWithSrcs(Register ResVReg,
10681062
return MIB.constrainAllUses(TII, TRI, RBI);
10691063
}
10701064

1071-
bool SPIRVInstructionSelector::selectStrictFMulAdd(Register ResVReg,
1072-
const SPIRVType *ResType,
1073-
MachineInstr &I) const {
1074-
MachineBasicBlock &BB = *I.getParent();
1075-
Register MulLHS = I.getOperand(1).getReg();
1076-
Register MulRHS = I.getOperand(2).getReg();
1077-
Register AddRHS = I.getOperand(3).getReg();
1078-
SPIRVType *MulLHSType = GR.getSPIRVTypeForVReg(MulLHS);
1079-
unsigned MulOpcode, AddOpcode;
1080-
if (MulLHSType->getOpcode() == SPIRV::OpTypeFloat) {
1081-
MulOpcode = SPIRV::OpFMulS;
1082-
AddOpcode = SPIRV::OpFAddS;
1083-
} else {
1084-
MulOpcode = SPIRV::OpFMulV;
1085-
AddOpcode = SPIRV::OpFAddV;
1086-
}
1087-
Register MulTemp = MRI->createVirtualRegister(MRI->getRegClass(MulLHS));
1088-
BuildMI(BB, I, I.getDebugLoc(), TII.get(MulOpcode))
1089-
.addDef(MulTemp)
1090-
.addUse(GR.getSPIRVTypeID(ResType))
1091-
.addUse(MulLHS)
1092-
.addUse(MulRHS)
1093-
.constrainAllUses(TII, TRI, RBI);
1094-
return BuildMI(BB, I, I.getDebugLoc(), TII.get(AddOpcode))
1095-
.addDef(ResVReg)
1096-
.addUse(GR.getSPIRVTypeID(ResType))
1097-
.addUse(MulTemp)
1098-
.addUse(AddRHS)
1099-
.constrainAllUses(TII, TRI, RBI);
1100-
}
1101-
11021065
bool SPIRVInstructionSelector::selectUnOp(Register ResVReg,
11031066
const SPIRVType *ResType,
11041067
MachineInstr &I,

llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,12 @@ SPIRVLegalizerInfo::SPIRVLegalizerInfo(const SPIRVSubtarget &ST) {
193193
.legalFor(allIntScalarsAndVectors)
194194
.legalIf(extendedScalarsAndVectors);
195195

196-
getActionDefinitionsBuilder({G_FMA, G_STRICT_FMA, G_STRICT_FMULADD})
196+
getActionDefinitionsBuilder({G_FMA, G_STRICT_FMA})
197197
.legalFor(allFloatScalarsAndVectors);
198198

199+
getActionDefinitionsBuilder(G_STRICT_FMAD)
200+
.lower();
201+
199202
getActionDefinitionsBuilder(G_STRICT_FLDEXP)
200203
.legalForCartesianProduct(allFloatScalarsAndVectors, allIntScalars);
201204

0 commit comments

Comments
 (0)