Skip to content

Commit 9892c86

Browse files
committed
Remove SVE handling and add pattern to compensate
1 parent ae2ba40 commit 9892c86

File tree

2 files changed

+20
-30
lines changed

2 files changed

+20
-30
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20708,42 +20708,31 @@ static SDValue performFMACombine(SDNode *N,
2070820708
// fma(a, b, neg(c)) -> fnmls(a, b, c)
2070920709
// fma(neg(a), b, neg(c)) -> fnmla(a, b, c)
2071020710
// fma(a, neg(b), neg(c)) -> fnmla(a, b, c)
20711-
if (!VT.isVector() || !DAG.getTargetLoweringInfo().isTypeLegal(VT) ||
20711+
if (!VT.isFixedLengthVector() ||
20712+
!DAG.getTargetLoweringInfo().isTypeLegal(VT) ||
2071220713
!Subtarget->isSVEorStreamingSVEAvailable() ||
2071320714
OpC.getOpcode() != ISD::FNEG) {
2071420715
return SDValue();
2071520716
}
2071620717

2071720718
SDValue Pg = getPredicateForVector(DAG, DL, VT);
20718-
EVT ContainerVT =
20719-
VT.isFixedLengthVector() ? getContainerForFixedLengthVector(DAG, VT) : VT;
20720-
OpC = VT.isFixedLengthVector()
20721-
? convertToScalableVector(DAG, ContainerVT, OpC.getOperand(0))
20722-
: OpC->getOperand(0);
20723-
OpC = DAG.getNode(AArch64ISD::FNEG_MERGE_PASSTHRU, DL, ContainerVT, Pg, OpC,
20724-
DAG.getUNDEF(ContainerVT));
20725-
20726-
if (OpB.getOpcode() == ISD::FNEG) {
20727-
std::swap(OpA, OpB);
20728-
}
20729-
20730-
if (OpA.getOpcode() == ISD::FNEG) {
20731-
OpA = VT.isFixedLengthVector()
20732-
? convertToScalableVector(DAG, ContainerVT, OpA.getOperand(0))
20733-
: OpA->getOperand(0);
20734-
OpA = DAG.getNode(AArch64ISD::FNEG_MERGE_PASSTHRU, DL, ContainerVT, Pg, OpA,
20735-
DAG.getUNDEF(ContainerVT));
20736-
} else if (VT.isFixedLengthVector()) {
20737-
OpA = convertToScalableVector(DAG, ContainerVT, OpA);
20738-
}
20739-
20740-
if (VT.isFixedLengthVector()) {
20741-
OpB = convertToScalableVector(DAG, ContainerVT, OpB);
20742-
SDValue ScalableRes =
20743-
DAG.getNode(AArch64ISD::FMA_PRED, DL, ContainerVT, Pg, OpA, OpB, OpC);
20744-
return convertFromScalableVector(DAG, VT, ScalableRes);
20745-
}
20746-
return DAG.getNode(AArch64ISD::FMA_PRED, DL, VT, Pg, OpA, OpB, OpC);
20719+
EVT ContainerVT = getContainerForFixedLengthVector(DAG, VT);
20720+
OpC =
20721+
DAG.getNode(AArch64ISD::FNEG_MERGE_PASSTHRU, DL, ContainerVT, Pg,
20722+
convertToScalableVector(DAG, ContainerVT, OpC.getOperand(0)),
20723+
DAG.getUNDEF(ContainerVT));
20724+
20725+
OpA = OpA.getOpcode() == ISD::FNEG
20726+
? DAG.getNode(
20727+
AArch64ISD::FNEG_MERGE_PASSTHRU, DL, ContainerVT, Pg,
20728+
convertToScalableVector(DAG, ContainerVT, OpA.getOperand(0)),
20729+
DAG.getUNDEF(ContainerVT))
20730+
: convertToScalableVector(DAG, ContainerVT, OpA);
20731+
20732+
OpB = convertToScalableVector(DAG, ContainerVT, OpB);
20733+
SDValue ScalableRes =
20734+
DAG.getNode(AArch64ISD::FMA_PRED, DL, ContainerVT, Pg, OpA, OpB, OpC);
20735+
return convertFromScalableVector(DAG, VT, ScalableRes);
2074720736
}
2074820737

2074920738
static bool hasPairwiseAdd(unsigned Opcode, EVT VT, bool FullFP16) {

llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ def AArch64fmlsidx : PatFrags<(ops node:$acc, node:$op1, node:$op2, node:$idx),
462462
def AArch64fnmla_p : PatFrags<(ops node:$pg, node:$za, node:$zn, node:$zm),
463463
[(int_aarch64_sve_fnmla_u node:$pg, node:$za, node:$zn, node:$zm),
464464
(AArch64fma_p node:$pg, (AArch64fneg_mt node:$pg, node:$zn, (undef)), node:$zm, (AArch64fneg_mt node:$pg, node:$za, (undef))),
465+
(AArch64fma_p node:$pg, node:$zn, (AArch64fneg_mt node:$pg, node:$zm, (undef)), (AArch64fneg_mt node:$pg, node:$za, (undef))),
465466
(AArch64fneg_mt_nsz node:$pg, (AArch64fma_p node:$pg, node:$zn, node:$zm, node:$za), (undef))]>;
466467

467468
def AArch64fnmls_p : PatFrags<(ops node:$pg, node:$za, node:$zn, node:$zm),

0 commit comments

Comments
 (0)