[llvm] [RISCV] Propagate SDNode flags when combining `(fmul (fneg X), ...)` (PR #169460)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 25 01:06:49 PST 2025


================
@@ -20822,7 +20822,7 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
     // Undo this and sink the fneg so we match more fmsub/fnmadd patterns.
     if (sd_match(N, m_FMul(m_Value(X), m_OneUse(m_FNeg(m_Value(Y))))))
       return DAG.getNode(ISD::FNEG, DL, VT,
-                         DAG.getNode(ISD::FMUL, DL, VT, X, Y));
+                         DAG.getNode(ISD::FMUL, DL, VT, X, Y, N->getFlags()));
----------------
lukel97 wrote:

Woops, thanks for fixing this. It looks like InstCombine propagates the flags to both the fmul and fneg, should we also propagate it to the fneg?

https://github.com/llvm/llvm-project/blob/2ce363d25226c2d502d19917ca8502115c953599/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp#L3015-L3021

https://github.com/llvm/llvm-project/pull/169460


More information about the llvm-commits mailing list