[llvm] Add `llvm.vector.partial.reduce.fadd` intrinsic (PR #159776)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 15 02:04:55 PDT 2025
================
@@ -12062,22 +12062,29 @@ SDValue TargetLowering::expandPartialReduceMLA(SDNode *N,
EVT::getVectorVT(*DAG.getContext(), AccVT.getVectorElementType(),
MulOpVT.getVectorElementCount());
- unsigned ExtOpcLHS = N->getOpcode() == ISD::PARTIAL_REDUCE_UMLA
- ? ISD::ZERO_EXTEND
- : ISD::SIGN_EXTEND;
- unsigned ExtOpcRHS = N->getOpcode() == ISD::PARTIAL_REDUCE_SMLA
- ? ISD::SIGN_EXTEND
- : ISD::ZERO_EXTEND;
+ unsigned ExtOpcLHS =
+ N->getOpcode() == ISD::PARTIAL_REDUCE_FMLA ? ISD::FP_EXTEND
+ : N->getOpcode() == ISD::PARTIAL_REDUCE_UMLA ? ISD::ZERO_EXTEND
+ : ISD::SIGN_EXTEND;
+ unsigned ExtOpcRHS =
+ N->getOpcode() == ISD::PARTIAL_REDUCE_FMLA ? ISD::FP_EXTEND
+ : N->getOpcode() == ISD::PARTIAL_REDUCE_SMLA ? ISD::SIGN_EXTEND
+ : ISD::ZERO_EXTEND;
if (ExtMulOpVT != MulOpVT) {
MulLHS = DAG.getNode(ExtOpcLHS, DL, ExtMulOpVT, MulLHS);
MulRHS = DAG.getNode(ExtOpcRHS, DL, ExtMulOpVT, MulRHS);
}
SDValue Input = MulLHS;
APInt ConstantOne;
- if (!ISD::isConstantSplatVector(MulRHS.getNode(), ConstantOne) ||
- !ConstantOne.isOne())
+ if (N->getOpcode() == ISD::PARTIAL_REDUCE_FMLA) {
+ ConstantFPSDNode *C = llvm::isConstOrConstSplatFP(MulRHS, false);
+ if (!(C && C->isExactlyValue(1.0)))
----------------
sdesmalen-arm wrote:
I think it makes sense to create a `llvm::isOneFPConstant(SDValue)` function for this (similar to how there is a `llvm::isNullFPConstant` and `llvm::isOneConstant`, and then to use `isOne[FP]Constant` in some of the other expressions in this PR.
https://github.com/llvm/llvm-project/pull/159776
More information about the llvm-commits
mailing list