[llvm] [SelectionDAG] Make sure demanded lanes for AND/MUL-by-zero are frozen (PR #180727)

Björn Pettersson via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 10 08:07:39 PST 2026


================
@@ -3806,19 +3806,22 @@ bool TargetLowering::SimplifyDemandedVectorElts(
     if (SimplifyDemandedVectorElts(Op1, DemandedElts, SrcUndef, SrcZero, TLO,
                                    Depth + 1))
       return true;
-    // If we know that a demanded element was zero in Op1 we don't need to
-    // demand it in Op0 - its guaranteed to be zero.
-    APInt DemandedElts0 = DemandedElts & ~SrcZero;
-    if (SimplifyDemandedVectorElts(Op0, DemandedElts0, KnownUndef, KnownZero,
+    // FIXME: If we know that a demanded element was zero in Op1 we don't need
+    // to demand it in Op0 - its guaranteed to be zero. There is however a
+    // restriction, as we must not make any of the originally demanded elements
+    // more poisonous. We could reduce amount of elements demanded, but then we
+    // also need a to inform SimplifyDemandedVectorElts that some elements must
+    // not be made more poisonous.
----------------
bjope wrote:

Isn't this the classical problem that as soon as we do not demand an element it can be turned into poison (even if it is guaranteed not to be poison before the call to SimplifyDemandedVectorElts). That is why we would need something like in https://github.com/llvm/llvm-project/pull/145903 that prevents from turning non-poison elements into poison (while for example replacing them by undef or simplifying them in any other way would be ok).

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


More information about the llvm-commits mailing list