Skip to content

Commit 30d3441

Browse files
authored
Revert "[WebAssembly] Lower fmuladd to madd and nmadd" (llvm#163171)
Reverts llvm#161355 Looks like I've broken some intrinsic code generation.
1 parent 3f3ca76 commit 30d3441

File tree

14 files changed

+51
-1439
lines changed

14 files changed

+51
-1439
lines changed

llvm/include/llvm/CodeGen/ISDOpcodes.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -514,12 +514,6 @@ enum NodeType {
514514
/// separately rounded operations.
515515
FMAD,
516516

517-
/// FMULADD - Performs a * b + c, with, or without, intermediate rounding.
518-
/// It is expected that this will be illegal for most targets, as it usually
519-
/// makes sense to split this or use an FMA. But some targets, such as
520-
/// WebAssembly, can directly support these semantics.
521-
FMULADD,
522-
523517
/// FCOPYSIGN(X, Y) - Return the value of X with the sign of Y. NOTE: This
524518
/// DAG node does not require that X and Y have the same type, just that
525519
/// they are both floating point. X and the result must have the same type.

llvm/include/llvm/Target/TargetSelectionDAG.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ def fdiv : SDNode<"ISD::FDIV" , SDTFPBinOp>;
535535
def frem : SDNode<"ISD::FREM" , SDTFPBinOp>;
536536
def fma : SDNode<"ISD::FMA" , SDTFPTernaryOp, [SDNPCommutative]>;
537537
def fmad : SDNode<"ISD::FMAD" , SDTFPTernaryOp, [SDNPCommutative]>;
538-
def fmuladd : SDNode<"ISD::FMULADD" , SDTFPTernaryOp, [SDNPCommutative]>;
539538
def fabs : SDNode<"ISD::FABS" , SDTFPUnaryOp>;
540539
def fminnum : SDNode<"ISD::FMINNUM" , SDTFPBinOp,
541540
[SDNPCommutative, SDNPAssociative]>;

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ namespace {
509509
SDValue visitFMUL(SDNode *N);
510510
template <class MatchContextClass> SDValue visitFMA(SDNode *N);
511511
SDValue visitFMAD(SDNode *N);
512-
SDValue visitFMULADD(SDNode *N);
513512
SDValue visitFDIV(SDNode *N);
514513
SDValue visitFREM(SDNode *N);
515514
SDValue visitFSQRT(SDNode *N);
@@ -1992,7 +1991,6 @@ SDValue DAGCombiner::visit(SDNode *N) {
19921991
case ISD::FMUL: return visitFMUL(N);
19931992
case ISD::FMA: return visitFMA<EmptyMatchContext>(N);
19941993
case ISD::FMAD: return visitFMAD(N);
1995-
case ISD::FMULADD: return visitFMULADD(N);
19961994
case ISD::FDIV: return visitFDIV(N);
19971995
case ISD::FREM: return visitFREM(N);
19981996
case ISD::FSQRT: return visitFSQRT(N);
@@ -18446,21 +18444,6 @@ SDValue DAGCombiner::visitFMAD(SDNode *N) {
1844618444
return SDValue();
1844718445
}
1844818446

18449-
SDValue DAGCombiner::visitFMULADD(SDNode *N) {
18450-
SDValue N0 = N->getOperand(0);
18451-
SDValue N1 = N->getOperand(1);
18452-
SDValue N2 = N->getOperand(2);
18453-
EVT VT = N->getValueType(0);
18454-
SDLoc DL(N);
18455-
18456-
// Constant fold FMULADD.
18457-
if (SDValue C =
18458-
DAG.FoldConstantArithmetic(ISD::FMULADD, DL, VT, {N0, N1, N2}))
18459-
return C;
18460-
18461-
return SDValue();
18462-
}
18463-
1846418447
// Combine multiple FDIVs with the same divisor into multiple FMULs by the
1846518448
// reciprocal.
1846618449
// E.g., (a / D; b / D;) -> (recip = 1.0 / D; a * recip; b * recip)

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5786,7 +5786,6 @@ bool SelectionDAG::canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
57865786
case ISD::FCOPYSIGN:
57875787
case ISD::FMA:
57885788
case ISD::FMAD:
5789-
case ISD::FMULADD:
57905789
case ISD::FP_EXTEND:
57915790
case ISD::FP_TO_SINT_SAT:
57925791
case ISD::FP_TO_UINT_SAT:
@@ -5905,7 +5904,6 @@ bool SelectionDAG::isKnownNeverNaN(SDValue Op, const APInt &DemandedElts,
59055904
case ISD::FCOSH:
59065905
case ISD::FTANH:
59075906
case ISD::FMA:
5908-
case ISD::FMULADD:
59095907
case ISD::FMAD: {
59105908
if (SNaN)
59115909
return true;
@@ -7233,7 +7231,7 @@ SDValue SelectionDAG::FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL,
72337231
}
72347232

72357233
// Handle fma/fmad special cases.
7236-
if (Opcode == ISD::FMA || Opcode == ISD::FMAD || Opcode == ISD::FMULADD) {
7234+
if (Opcode == ISD::FMA || Opcode == ISD::FMAD) {
72377235
assert(VT.isFloatingPoint() && "This operator only applies to FP types!");
72387236
assert(Ops[0].getValueType() == VT && Ops[1].getValueType() == VT &&
72397237
Ops[2].getValueType() == VT && "FMA types must match!");
@@ -7244,7 +7242,7 @@ SDValue SelectionDAG::FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL,
72447242
APFloat V1 = C1->getValueAPF();
72457243
const APFloat &V2 = C2->getValueAPF();
72467244
const APFloat &V3 = C3->getValueAPF();
7247-
if (Opcode == ISD::FMAD || Opcode == ISD::FMULADD) {
7245+
if (Opcode == ISD::FMAD) {
72487246
V1.multiply(V2, APFloat::rmNearestTiesToEven);
72497247
V1.add(V3, APFloat::rmNearestTiesToEven);
72507248
} else

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6996,13 +6996,6 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
69966996
getValue(I.getArgOperand(0)),
69976997
getValue(I.getArgOperand(1)),
69986998
getValue(I.getArgOperand(2)), Flags));
6999-
} else if (TLI.isOperationLegalOrCustom(ISD::FMULADD, VT)) {
7000-
// TODO: Support splitting the vector.
7001-
setValue(&I, DAG.getNode(ISD::FMULADD, sdl,
7002-
getValue(I.getArgOperand(0)).getValueType(),
7003-
getValue(I.getArgOperand(0)),
7004-
getValue(I.getArgOperand(1)),
7005-
getValue(I.getArgOperand(2)), Flags));
70066999
} else {
70077000
// TODO: Intrinsic calls should have fast-math-flags.
70087001
SDValue Mul = DAG.getNode(

llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const {
310310
case ISD::FMA: return "fma";
311311
case ISD::STRICT_FMA: return "strict_fma";
312312
case ISD::FMAD: return "fmad";
313-
case ISD::FMULADD: return "fmuladd";
314313
case ISD::FREM: return "frem";
315314
case ISD::STRICT_FREM: return "strict_frem";
316315
case ISD::FCOPYSIGN: return "fcopysign";

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7676,7 +7676,6 @@ SDValue TargetLowering::getNegatedExpression(SDValue Op, SelectionDAG &DAG,
76767676
break;
76777677
}
76787678
case ISD::FMA:
7679-
case ISD::FMULADD:
76807679
case ISD::FMAD: {
76817680
if (!Flags.hasNoSignedZeros())
76827681
break;

llvm/lib/CodeGen/TargetLoweringBase.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,7 @@ void TargetLoweringBase::initActions() {
815815
ISD::FTAN, ISD::FACOS,
816816
ISD::FASIN, ISD::FATAN,
817817
ISD::FCOSH, ISD::FSINH,
818-
ISD::FTANH, ISD::FATAN2,
819-
ISD::FMULADD},
818+
ISD::FTANH, ISD::FATAN2},
820819
VT, Expand);
821820

822821
// Overflow operations default to expand

llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -317,15 +317,6 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
317317
setOperationAction(ISD::ZERO_EXTEND_VECTOR_INREG, T, Custom);
318318
}
319319

320-
if (Subtarget->hasFP16()) {
321-
setOperationAction(ISD::FMA, MVT::v8f16, Legal);
322-
}
323-
324-
if (Subtarget->hasRelaxedSIMD()) {
325-
setOperationAction(ISD::FMULADD, MVT::v4f32, Legal);
326-
setOperationAction(ISD::FMULADD, MVT::v2f64, Legal);
327-
}
328-
329320
// Partial MLA reductions.
330321
for (auto Op : {ISD::PARTIAL_REDUCE_SMLA, ISD::PARTIAL_REDUCE_UMLA}) {
331322
setPartialReduceMLAAction(Op, MVT::v4i32, MVT::v16i8, Legal);
@@ -1129,18 +1120,6 @@ WebAssemblyTargetLowering::getPreferredVectorAction(MVT VT) const {
11291120
return TargetLoweringBase::getPreferredVectorAction(VT);
11301121
}
11311122

1132-
bool WebAssemblyTargetLowering::isFMAFasterThanFMulAndFAdd(
1133-
const MachineFunction &MF, EVT VT) const {
1134-
if (!Subtarget->hasFP16() || !VT.isVector())
1135-
return false;
1136-
1137-
EVT ScalarVT = VT.getScalarType();
1138-
if (!ScalarVT.isSimple())
1139-
return false;
1140-
1141-
return ScalarVT.getSimpleVT().SimpleTy == MVT::f16;
1142-
}
1143-
11441123
bool WebAssemblyTargetLowering::shouldSimplifyDemandedVectorElts(
11451124
SDValue Op, const TargetLoweringOpt &TLO) const {
11461125
// ISel process runs DAGCombiner after legalization; this step is called

llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ class WebAssemblyTargetLowering final : public TargetLowering {
8181

8282
TargetLoweringBase::LegalizeTypeAction
8383
getPreferredVectorAction(MVT VT) const override;
84-
bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
85-
EVT VT) const override;
8684

8785
SDValue LowerCall(CallLoweringInfo &CLI,
8886
SmallVectorImpl<SDValue> &InVals) const override;

0 commit comments

Comments
 (0)