[llvm] [DAG] canCreateUndefOrPoison/isGuaranteedNotToBeUndefOrPoison - SCALAR_TO_VECTOR upper elements are poison (PR #217185)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 00:47:41 PDT 2026


================
@@ -3352,11 +3352,9 @@ bool TargetLowering::SimplifyDemandedVectorElts(
 
   switch (Opcode) {
   case ISD::SCALAR_TO_VECTOR: {
-    if (!DemandedElts[0]) {
-      KnownUndef.setAllBits();
-      return TLO.CombineTo(Op, TLO.DAG.getUNDEF(VT));
-    }
-    KnownUndef.setHighBits(NumElts - 1);
+    if (!DemandedElts[0])
+      return TLO.CombineTo(Op, TLO.DAG.getPOISON(VT));
+    // Upper elements are poison, not undef - don't mark them as KnownUndef.
----------------
RKSimon wrote:

At least one of the problems I known of is x86 shuffle combining using it as part of a AND(0,undef) -> 0 fold (vs AND(0,poison) -> poison).

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


More information about the llvm-commits mailing list