[llvm-branch-commits] [llvm] [DAGCombiner][GlobalISel] Prevent FMA contraction when fmul cannot be eliminated (FADD/FSUB pattern) (PR #188114)

Adel Ejjeh via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Apr 10 08:17:48 PDT 2026


================
@@ -17678,6 +17678,30 @@ static bool isFusedOp(const MatchContextClass &Matcher, SDValue N) {
   return Matcher.match(N, ISD::FMA) || Matcher.match(N, ISD::FMAD);
 }
 
+/// Check if all uses of a multiply can be contracted into FMA operations.
+/// Returns true if all uses of the multiply are contractable, meaning the
+/// multiply can potentially be eliminated through FMA contraction.
+/// Returns false if any use cannot be contracted, which would mean contracting
+/// would duplicate the multiply without reducing the total number of
+/// operations.
+///
+/// Currently checks for the following pattern:
+///   - fmul --> fadd/fsub: Direct contraction
+static bool allMulUsesCanBeContracted(SDValue Mul) {
----------------
adelejjeh wrote:

Yes this was split into a stacked PR based on the request of Matt. Each new PR adds new checks to the function (both here and in CombinerHerlep.cpp). Are you OK with it staying as is in that case?

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


More information about the llvm-branch-commits mailing list