[llvm] [DAG] Fold nested add(add(reduce(a), b), add(reduce(c), d)) (PR #115150)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 25 08:57:05 PST 2024
================
@@ -1329,6 +1329,28 @@ SDValue DAGCombiner::reassociateReduction(unsigned RedOpc, unsigned Opc,
DAG.getNode(Opc, DL, N0.getOperand(0).getValueType(),
N0.getOperand(0), N1.getOperand(0)));
}
+
+ // Reassociate op(op(vecreduce(a), b), op(vecreduce(c), d)) into
+ // op(vecreduce(op(a, c)), op(b, d)), to combine the reductions into a
+ // single node.
+ SDValue A, B, C, D;
+ if (sd_match(N0,
+ m_OneUse(m_c_BinOp(Opc, m_OneUse(m_UnaryOp(RedOpc, m_Value(A))),
----------------
david-arm wrote:
Thanks for this! Is it worth adding an extra test in CodeGen/AArch64/double_reduct.ll, i.e. something like `nested_mul_f32_mixed_reassoc`?
https://github.com/llvm/llvm-project/pull/115150
More information about the llvm-commits
mailing list