[llvm] [SelectionDAG] Deal with POISON for INSERT_VECTOR_ELT/INSERT_SUBVECTOR (part 1) (PR #143102)

Björn Pettersson via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 26 09:04:05 PDT 2025


================
@@ -27560,18 +27575,42 @@ SDValue DAGCombiner::visitINSERT_SUBVECTOR(SDNode *N) {
   SDValue N2 = N->getOperand(2);
   uint64_t InsIdx = N->getConstantOperandVal(2);
 
-  // If inserting an UNDEF, just return the original vector.
-  if (N1.isUndef())
-    return N0;
+  // If inserting an UNDEF, just return the original vector (unless it makes the
+  // result more poisonous).
+  if (N1.isUndef()) {
+    if (N1.getOpcode() == ISD::POISON)
+      return N0;
----------------
bjope wrote:

I think I tried that, but it never triggered. So I didn't want to add a combine that would be "dead code".

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


More information about the llvm-commits mailing list