[llvm] [SLPVectorizer] Handle undef values in reused shuffle masks (PR #219662)

Oscar Priego via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 29 10:16:42 PDT 2026


================
@@ -22881,7 +22881,7 @@ ResTy BoUpSLP::processBuildVector(const TreeEntry *E, Type *ScalarTy,
           std::iota(Mask.begin(), Mask.end(), 0);
         } else {
           for (auto [I, V] : enumerate(E->Scalars)) {
-            if (isa<PoisonValue>(V)) {
+            if (isa<UndefValue>(V)) {
----------------
Opriego wrote:

Thanks, you're right. Treating every undef as PoisonMaskElem was too broad and could introduce additional poison.

I've updated the patch so the perfect-diamond reuse path is only taken when every non-poison value is actually representable by the reused TreeEntry. An undef that only matched through the permissive isSame() poison rule now rejects that fast path instead, preserving the original undef semantics.

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


More information about the llvm-commits mailing list