[llvm] [DAG] Fold nested add(add(reduce(a), b), add(reduce(c), d)) (PR #115150)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 21 05:07:13 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))),
----------------
davemgreen wrote:
Yeah we probably do have to test that - I have tried to add something. Hopefully it is not too messy, and will do OK in practice.
https://github.com/llvm/llvm-project/pull/115150
More information about the llvm-commits
mailing list