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

Christudasan Devadasan via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Apr 5 22:26:20 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) {
----------------
cdevadas wrote:

Realized that it is part of a stacked PR, and you've extended this function to accommodate more cases. Integrating llvm::all_of would not effectively cover all scenarios.

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


More information about the llvm-branch-commits mailing list