[llvm] [SLP]Model copyable lanes of idempotent binops as op(V, V) when the operand column has a constant lane (PR #220252)

Ryan Buchner via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 11 10:56:24 PDT 2026


================
@@ -4581,12 +4581,20 @@ class slpvectorizer::BoUpSLP {
               .insert(CD);
           // Remove extra deps for users, becoming non-immediate users of the
           // instruction. It may happen, if the chain of same copyable elements
-          // appears in the tree.
+          // appears in the tree. With the self-operand modeling (op(V, V)) the
+          // user node has the value on more than one operand column, so its
+          // copyable data releases the instruction's schedule data directly
+          // and must stay a counted user.
           if (In == I) {
-            EdgeInfo UserEI = EI.UserTE->UserTreeIndex;
-            if (ScheduleCopyableData *UserCD =
-                    getScheduleCopyableData(UserEI, In))
-              ScheduleCopyableDataMapByUsers[I].remove(UserCD);
+            unsigned NumCols = 0;
+            for (unsigned OpIdx : seq<unsigned>(EI.UserTE->getNumOperands()))
+              NumCols += EI.UserTE->getOperand(OpIdx)[Lane] == I;
+            if (NumCols <= 1) {
+              EdgeInfo UserEI = EI.UserTE->UserTreeIndex;
+              if (ScheduleCopyableData *UserCD =
+                      getScheduleCopyableData(UserEI, In))
+                ScheduleCopyableDataMapByUsers[I].remove(UserCD);
+            }
----------------
bababuck wrote:

Could you explain this change to the scheduler more in depth. I understand the prior version where we remove `UserCD` from `ScheduleCopyableDataMapByUsers` in the case of a chain, but I'm struggling to comprehend why the change is needed here.

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


More information about the llvm-commits mailing list