[llvm-branch-commits] [llvm] [SLP] Propagate lost IR flags to vectorized casts (PR #237240)

Dmitry Sidorov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Oct 30 07:58:17 PDT 2026


================
@@ -24232,11 +24232,19 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
     if (!I)
       return V;
     // Drop nneg propagated from the original cast.
-    Value *Op;
     if (auto *CI = dyn_cast<CastInst>(VL0);
-        CI && match(I, m_NNegZExt(m_Value(Op))) &&
-        Op->getType()->getScalarType() != CI->getSrcTy())
-      cast<ZExtInst>(I)->setNonNeg(false);
+        CI && isa<PossiblyNonNegInst>(I) &&
+        I->getOperand(0)->getType()->getScalarType() !=
+            CI->getSrcTy()->getScalarType())
+      I->setNonNeg(false);
+    // A copyable zext lane is a zext of a truncated constant, which may be
+    // negative or undef.
----------------
MrSidims wrote:

Similar to 6359e4868465, this check prevents incorrect propagation of nneg. A copyable lane may introduce a constant that becomes negative after truncation, causing the vectorized zext nneg to produce poison.

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


More information about the llvm-branch-commits mailing list