[llvm] [SLP] Merge redundant input operands of binary-operator nodes (PR #208670)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 11 10:09:42 PDT 2026


================
@@ -28704,6 +29005,16 @@ bool BoUpSLP::collectValuesToDemote(
         ToDemote.push_back(E.Idx);
         return IsProfitableToDemote;
       };
+  // The operand count is not always two: a flattened node has one entry per
+  // reassociated column, and a node whose input operands were merged has a
+  // single shared operand entry. Collect the entries by the actual number of
+  // operand columns.
+  auto GetOperandEntries = [&]() {
+    return map_to_vector(seq<unsigned>(E.getNumOperands()),
+                         [&](unsigned Idx) -> const TreeEntry * {
+                           return getOperandEntry(&E, Idx);
+                         });
+  };
----------------
alexey-bataev wrote:

Main part of this can be fixed in a separate NFC patch

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


More information about the llvm-commits mailing list