[llvm] [SLP]Initial support for copyable elements (non-schedulable only) (PR #140279)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 17 10:27:28 PDT 2025


================
@@ -2892,13 +2946,20 @@ class BoUpSLP {
         // Since operand reordering is performed on groups of commutative
         // operations or alternating sequences (e.g., +, -), we can safely tell
         // the inverse operations by checking commutativity.
-        if (isa<PoisonValue>(V)) {
+        auto *I = dyn_cast<Instruction>(VL[Lane]);
+        if (!I && isa<PoisonValue>(VL[Lane])) {
           for (unsigned OpIdx : seq<unsigned>(NumOperands))
             OpsVec[OpIdx][Lane] = {Operands[OpIdx][Lane], true, false};
           continue;
         }
-        auto [SelectedOp, Ops] = convertTo(cast<Instruction>(V), S);
-        bool IsInverseOperation = !isCommutative(SelectedOp);
+        bool IsInverseOperation = false;
+        if (S.isCopyableElement(VL[Lane])) {
+          // The value is a copyable element.
+          IsInverseOperation = !isCommutative(MainOp);
+        } else {
+          auto [SelectedOp, Ops] = convertTo(I, S);
----------------
alexey-bataev wrote:

Added assertion

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


More information about the llvm-commits mailing list