[llvm] [SLP] Only consider BuildVector inserts into the same object. (PR #212269)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 27 08:58:11 PDT 2026


================
@@ -23148,9 +23148,14 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
               InsertMask[*InsertIdx] = *InsertIdx;
             if (!Ins->hasOneUse())
               break;
-            Ins =
+            auto *User =
                 dyn_cast_or_null<Instruction>(Ins->getUniqueUndroppableUser());
-          } while (Ins);
+            // Only continue while the user extends the same buildvector, i.e.
+            // it inserts into the value built so far.
+            if (!User || User->getOperand(0) != Ins)
+              break;
+            Ins = User;
+          } while (true);
----------------
fhahn wrote:

Updated thanks. `Op` needed to be declared outside the loop

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


More information about the llvm-commits mailing list