[llvm] relaxed simd fma (PR #147487)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 8 02:12:51 PDT 2025
================
@@ -3412,6 +3418,37 @@ static SDValue performSETCCCombine(SDNode *N,
return SDValue();
}
+static SDValue performFAddCombine(SDNode *N, SelectionDAG &DAG) {
+ assert(N->getOpcode() == ISD::FADD);
+ using namespace llvm::SDPatternMatch;
+ if (!N->getFlags().hasFastMath())
+ return SDValue();
+
+ SDLoc DL(N);
+ SDValue A, B, C;
+ EVT VecVT = N->getValueType(0);
+ if (sd_match(N, m_FAdd(m_Value(A), m_FMul(m_Value(B), m_Value(C)))))
+ return DAG.getNode(
+ ISD::INTRINSIC_WO_CHAIN, DL, VecVT,
+ {DAG.getConstant(Intrinsic::wasm_relaxed_madd, DL, MVT::i32), A, B, C});
+
+ return SDValue();
+}
+
+static SDValue performFMACombine(SDNode *N, SelectionDAG &DAG) {
+ assert(N->getOpcode() == ISD::FMA);
+ if (!N->getFlags().hasFastMath())
+ return SDValue();
+
+ SDLoc DL(N);
+ SDValue A = N->getOperand(0), B = N->getOperand(1), C = N->getOperand(2);
+ EVT VecVT = N->getValueType(0);
+
+ return DAG.getNode(
+ ISD::INTRINSIC_WO_CHAIN, DL, VecVT,
+ {DAG.getConstant(Intrinsic::wasm_relaxed_madd, DL, MVT::i32), A, B, C});
+}
----------------
arsenm wrote:
I doubt it's appropriate to turn an FMA into a not-FMA, regardless of fast math flags. What are the semantics of wasm_relaxed_madd?
https://github.com/llvm/llvm-project/pull/147487
More information about the llvm-commits
mailing list