[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
Wed Nov 6 08:11:43 PST 2024


================
@@ -1329,6 +1329,38 @@ SDValue DAGCombiner::reassociateReduction(unsigned RedOpc, unsigned Opc,
                        DAG.getNode(Opc, DL, N0.getOperand(0).getValueType(),
                                    N0.getOperand(0), N1.getOperand(0)));
   }
+
+  // Reassociate add(add(vecreduce(a), b), add(vecreduce(c), d)) into
----------------
david-arm wrote:

Given this pattern is used for all operations (not just add) perhaps worth rewriting the comment to be something like:

```
  // 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.
```

?

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


More information about the llvm-commits mailing list