[llvm] [SLP] More accurately cost RISCV scalar splats (PR #213104)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 13 07:35:19 PDT 2026


================
@@ -23006,10 +23057,28 @@ ResTy BoUpSLP::processBuildVector(const TreeEntry *E, Type *ScalarTy,
     // Gather unique scalars and all constants.
     SmallVector<int> ReuseMask(GatheredScalars.size(), PoisonMaskElem);
     TryPackScalars(GatheredScalars, ReuseMask, /*IsRootPoison=*/true);
-    Value *BV = ShuffleBuilder.gather(GatheredScalars, ReuseMask.size());
-    ShuffleBuilder.add(BV, ReuseMask);
+    auto CanSplatAllUsers = [&]() {
+      for (const auto &TE : VectorizableTree) {
+        if (DeletedNodes.contains(TE.get()))
+          continue;
+        if (!TE->isGather() || !E->isSame(TE->Scalars))
----------------
alexey-bataev wrote:

```suggestion
        if (!TE->isGather() || !E->isSame(TE->Scalars) || !TransformedToGathers.contains(TE))
```

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


More information about the llvm-commits mailing list