Skip to content

[SelectionDAG] Introducing a new ISD::POISON SDNode to represent the poison value in the IR. #125883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 7, 2025

Conversation

diggerlin
Copy link
Contributor

@diggerlin diggerlin commented Feb 5, 2025

A new ISD::POISON SDNode is introduced to represent the poison value in the IR, replacing the previous use of ISD::UNDEF.

@llvmbot llvmbot added the llvm:SelectionDAG SelectionDAGISel as well label Feb 5, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 5, 2025

@llvm/pr-subscribers-backend-systemz
@llvm/pr-subscribers-backend-x86
@llvm/pr-subscribers-backend-arm
@llvm/pr-subscribers-backend-risc-v
@llvm/pr-subscribers-backend-aarch64

@llvm/pr-subscribers-llvm-selectiondag

Author: zhijian lin (diggerlin)

Changes

A new ISD::POISON SDNode is introduced to represent the poison value in the IR, replacing the previous use of ISD::UNDEF.


Full diff: https://github.com/llvm/llvm-project/pull/125883.diff

12 Files Affected:

  • (modified) llvm/include/llvm/CodeGen/ISDOpcodes.h (+3)
  • (modified) llvm/include/llvm/CodeGen/SelectionDAG.h (+5-2)
  • (modified) llvm/include/llvm/CodeGen/SelectionDAGNodes.h (+11-2)
  • (modified) llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (+7-6)
  • (modified) llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (+17)
  • (modified) llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp (+4)
  • (modified) llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (+2)
  • (modified) llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (+3)
  • (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (+20-11)
  • (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp (+1)
  • (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (+1)
diff --git a/llvm/include/llvm/CodeGen/ISDOpcodes.h b/llvm/include/llvm/CodeGen/ISDOpcodes.h
index 604dc9419025b09..cdb0d4b92bbf709 100644
--- a/llvm/include/llvm/CodeGen/ISDOpcodes.h
+++ b/llvm/include/llvm/CodeGen/ISDOpcodes.h
@@ -217,6 +217,9 @@ enum NodeType {
   /// UNDEF - An undefined node.
   UNDEF,
 
+  /// POISON - A poison node.
+  POISON,
+
   /// FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or
   /// is evaluated to UNDEF), or returns VAL otherwise. Note that each
   /// read of UNDEF can yield different value, but FREEZE(UNDEF) cannot.
diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h
index b31ad11c3ee0ee8..04d72eca9a35be2 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAG.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -871,7 +871,7 @@ class SelectionDAG {
   /// for integers, a type wider than) VT's element type.
   SDValue getSplatBuildVector(EVT VT, const SDLoc &DL, SDValue Op) {
     // VerifySDNode (via InsertNode) checks BUILD_VECTOR later.
-    if (Op.getOpcode() == ISD::UNDEF) {
+    if (Op.isUndef()) {
       assert((VT.getVectorElementType() == Op.getValueType() ||
               (VT.isInteger() &&
                VT.getVectorElementType().bitsLE(Op.getValueType()))) &&
@@ -887,7 +887,7 @@ class SelectionDAG {
   // Return a splat ISD::SPLAT_VECTOR node, consisting of Op splatted to all
   // elements.
   SDValue getSplatVector(EVT VT, const SDLoc &DL, SDValue Op) {
-    if (Op.getOpcode() == ISD::UNDEF) {
+    if (Op.isUndef()) {
       assert((VT.getVectorElementType() == Op.getValueType() ||
               (VT.isInteger() &&
                VT.getVectorElementType().bitsLE(Op.getValueType()))) &&
@@ -1128,6 +1128,9 @@ class SelectionDAG {
     return getNode(ISD::UNDEF, SDLoc(), VT);
   }
 
+  /// Return an POISON node. POISON does not have a useful SDLoc.
+  SDValue getPoison(EVT VT) { return getNode(ISD::POISON, SDLoc(), VT); }
+
   /// Return a node that represents the runtime scaling 'MulImm * RuntimeVL'.
   SDValue getVScale(const SDLoc &DL, EVT VT, APInt MulImm,
                     bool ConstantFold = true);
diff --git a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
index 03899493847b394..c98c9da43a30804 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -690,8 +690,17 @@ END_TWO_BYTE_PACK()
   /// \<target\>ISD namespace).
   bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
 
-  /// Return true if the type of the node type undefined.
-  bool isUndef() const { return NodeType == ISD::UNDEF; }
+  /// Returns true if the node type is UNDEF or, when UndefOnly is false,
+  /// POISON.
+  /// - When UndefOnly is true, returns true only for UNDEF.
+  /// - When UndefOnly is false, returns true for both UNDEF and POISON.
+  /// @param UndefOnly Determines whether to check only for UNDEF.
+  bool isUndef(bool UndefOnly = false) const {
+    return NodeType == ISD::UNDEF || (!UndefOnly && NodeType == ISD::POISON);
+  }
+
+  /// Return true if the type of the node type poison.
+  bool isPoison() const { return NodeType == ISD::POISON; }
 
   /// Test if this node is a memory intrinsic (with valid pointer information).
   bool isMemIntrinsic() const { return SDNodeBits.IsMemIntrinsic; }
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 02b79c67af3ee07..ce776214df1f1e4 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -16156,7 +16156,7 @@ SDValue DAGCombiner::visitFREEZE(SDNode *N) {
     // also recursively replace t184 by t150.
     SDValue MaybePoisonOperand = N->getOperand(0).getOperand(OpNo);
     // Don't replace every single UNDEF everywhere with frozen UNDEF, though.
-    if (MaybePoisonOperand.getOpcode() == ISD::UNDEF)
+    if (MaybePoisonOperand.isUndef())
       continue;
     // First, freeze each offending operand.
     SDValue FrozenMaybePoisonOperand = DAG.getFreeze(MaybePoisonOperand);
@@ -16182,9 +16182,10 @@ SDValue DAGCombiner::visitFREEZE(SDNode *N) {
   // Finally, recreate the node, it's operands were updated to use
   // frozen operands, so we just need to use it's "original" operands.
   SmallVector<SDValue> Ops(N0->ops());
-  // Special-handle ISD::UNDEF, each single one of them can be it's own thing.
+  // Special-handle ISD::UNDEF, ISD::POISON, each single one of them can be it's
+  // own thing.
   for (SDValue &Op : Ops) {
-    if (Op.getOpcode() == ISD::UNDEF)
+    if (Op.isUndef())
       Op = DAG.getFreeze(Op);
   }
 
@@ -24320,7 +24321,7 @@ static SDValue combineConcatVectorOfScalars(SDNode *N, SelectionDAG &DAG) {
     if (ISD::BITCAST == Op.getOpcode() &&
         !Op.getOperand(0).getValueType().isVector())
       Ops.push_back(Op.getOperand(0));
-    else if (ISD::UNDEF == Op.getOpcode())
+    else if (Op.isUndef())
       Ops.push_back(DAG.getNode(ISD::UNDEF, DL, SVT));
     else
       return SDValue();
@@ -24715,7 +24716,7 @@ SDValue DAGCombiner::visitCONCAT_VECTORS(SDNode *N) {
   // fold (concat_vectors (BUILD_VECTOR A, B, ...), (BUILD_VECTOR C, D, ...))
   // -> (BUILD_VECTOR A, B, ..., C, D, ...)
   auto IsBuildVectorOrUndef = [](const SDValue &Op) {
-    return ISD::UNDEF == Op.getOpcode() || ISD::BUILD_VECTOR == Op.getOpcode();
+    return Op.isUndef() || ISD::BUILD_VECTOR == Op.getOpcode();
   };
   if (llvm::all_of(N->ops(), IsBuildVectorOrUndef)) {
     SmallVector<SDValue, 8> Opnds;
@@ -24739,7 +24740,7 @@ SDValue DAGCombiner::visitCONCAT_VECTORS(SDNode *N) {
       EVT OpVT = Op.getValueType();
       unsigned NumElts = OpVT.getVectorNumElements();
 
-      if (ISD::UNDEF == Op.getOpcode())
+      if (Op.isUndef())
         Opnds.append(NumElts, DAG.getUNDEF(MinVT));
 
       if (ISD::BUILD_VECTOR == Op.getOpcode()) {
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index c6475f02199033d..7a84d695ccc5a57 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -977,6 +977,22 @@ void SelectionDAGLegalize::LegalizeOp(SDNode *Node) {
   TargetLowering::LegalizeAction Action = TargetLowering::Legal;
   bool SimpleFinishLegalizing = true;
   switch (Node->getOpcode()) {
+  // FIXME: If the node represents a poison value, replace it with an undef
+  // value.
+  //  A poison value results from an erroneous operation but does not cause
+  //  immediate undefined behavior, allowing speculative execution.
+  //  Since most operations propagate poison, it is valid to replace poison
+  //  with an undef value, which can take any legal value of the same type.
+  //  This ensures that downstream computations do not rely on poison semantics.
+  //  Poison is more restrictive than undef. Since we replace poison with undef
+  //  here, the poison information will be lost after the code is executed. In
+  //  the futher, If we need to retain the poison information after the code is
+  //  executed, we will need to modify the code accordingly.
+  case ISD::POISON: {
+    SDValue UndefNode = DAG.getUNDEF(Node->getValueType(0));
+    ReplaceNode(Node, UndefNode.getNode());
+    break;
+  }
   case ISD::INTRINSIC_W_CHAIN:
   case ISD::INTRINSIC_WO_CHAIN:
   case ISD::INTRINSIC_VOID:
@@ -3136,6 +3152,7 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
     for (unsigned i = 0; i < Node->getNumValues(); i++)
       Results.push_back(Node->getOperand(i));
     break;
+  case ISD::POISON:
   case ISD::UNDEF: {
     EVT VT = Node->getValueType(0);
     if (VT.isInteger())
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
index 71f100bfa034343..1c28722f3f0a284 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
@@ -164,6 +164,7 @@ void DAGTypeLegalizer::SoftenFloatResult(SDNode *N, unsigned ResNo) {
     case ISD::STRICT_UINT_TO_FP:
     case ISD::SINT_TO_FP:
     case ISD::UINT_TO_FP:  R = SoftenFloatRes_XINT_TO_FP(N); break;
+    case ISD::POISON:
     case ISD::UNDEF:       R = SoftenFloatRes_UNDEF(N); break;
     case ISD::VAARG:       R = SoftenFloatRes_VAARG(N); break;
     case ISD::VECREDUCE_FADD:
@@ -1474,6 +1475,7 @@ void DAGTypeLegalizer::ExpandFloatResult(SDNode *N, unsigned ResNo) {
     report_fatal_error("Do not know how to expand the result of this "
                        "operator!");
     // clang-format off
+  case ISD::POISON:
   case ISD::UNDEF:        SplitRes_UNDEF(N, Lo, Hi); break;
   case ISD::SELECT:       SplitRes_Select(N, Lo, Hi); break;
   case ISD::SELECT_CC:    SplitRes_SELECT_CC(N, Lo, Hi); break;
@@ -2783,6 +2785,7 @@ void DAGTypeLegalizer::PromoteFloatResult(SDNode *N, unsigned ResNo) {
 
     case ISD::SINT_TO_FP:
     case ISD::UINT_TO_FP: R = PromoteFloatRes_XINT_TO_FP(N); break;
+    case ISD::POISON:
     case ISD::UNDEF:      R = PromoteFloatRes_UNDEF(N); break;
     case ISD::ATOMIC_SWAP: R = BitcastToInt_ATOMIC_SWAP(N); break;
     case ISD::VECREDUCE_FADD:
@@ -3242,6 +3245,7 @@ void DAGTypeLegalizer::SoftPromoteHalfResult(SDNode *N, unsigned ResNo) {
   case ISD::STRICT_UINT_TO_FP:
   case ISD::SINT_TO_FP:
   case ISD::UINT_TO_FP:  R = SoftPromoteHalfRes_XINT_TO_FP(N); break;
+  case ISD::POISON:
   case ISD::UNDEF:       R = SoftPromoteHalfRes_UNDEF(N); break;
   case ISD::ATOMIC_SWAP: R = BitcastToInt_ATOMIC_SWAP(N); break;
   case ISD::VECREDUCE_FADD:
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
index be7521f34168503..4da7bf9a680abe1 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
@@ -118,6 +118,7 @@ void DAGTypeLegalizer::PromoteIntegerResult(SDNode *N, unsigned ResNo) {
   case ISD::VP_SRL:      Res = PromoteIntRes_SRL(N); break;
   case ISD::VP_TRUNCATE:
   case ISD::TRUNCATE:    Res = PromoteIntRes_TRUNCATE(N); break;
+  case ISD::POISON:
   case ISD::UNDEF:       Res = PromoteIntRes_UNDEF(N); break;
   case ISD::VAARG:       Res = PromoteIntRes_VAARG(N); break;
   case ISD::VSCALE:      Res = PromoteIntRes_VSCALE(N); break;
@@ -2840,6 +2841,7 @@ void DAGTypeLegalizer::ExpandIntegerResult(SDNode *N, unsigned ResNo) {
   case ISD::MERGE_VALUES: SplitRes_MERGE_VALUES(N, ResNo, Lo, Hi); break;
   case ISD::SELECT:       SplitRes_Select(N, Lo, Hi); break;
   case ISD::SELECT_CC:    SplitRes_SELECT_CC(N, Lo, Hi); break;
+  case ISD::POISON:
   case ISD::UNDEF:        SplitRes_UNDEF(N, Lo, Hi); break;
   case ISD::FREEZE:       SplitRes_FREEZE(N, Lo, Hi); break;
   case ISD::SETCC:        ExpandIntRes_SETCC(N, Lo, Hi); break;
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
index 5117eb8d91dfb21..37aad1e21f7bd2b 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
@@ -71,6 +71,7 @@ void DAGTypeLegalizer::ScalarizeVectorResult(SDNode *N, unsigned ResNo) {
   case ISD::SELECT:            R = ScalarizeVecRes_SELECT(N); break;
   case ISD::SELECT_CC:         R = ScalarizeVecRes_SELECT_CC(N); break;
   case ISD::SETCC:             R = ScalarizeVecRes_SETCC(N); break;
+  case ISD::POISON:
   case ISD::UNDEF:             R = ScalarizeVecRes_UNDEF(N); break;
   case ISD::VECTOR_SHUFFLE:    R = ScalarizeVecRes_VECTOR_SHUFFLE(N); break;
   case ISD::IS_FPCLASS:        R = ScalarizeVecRes_IS_FPCLASS(N); break;
@@ -1117,6 +1118,7 @@ void DAGTypeLegalizer::SplitVectorResult(SDNode *N, unsigned ResNo) {
   case ISD::VP_MERGE:
   case ISD::VP_SELECT:    SplitRes_Select(N, Lo, Hi); break;
   case ISD::SELECT_CC:    SplitRes_SELECT_CC(N, Lo, Hi); break;
+  case ISD::POISON:
   case ISD::UNDEF:        SplitRes_UNDEF(N, Lo, Hi); break;
   case ISD::BITCAST:           SplitVecRes_BITCAST(N, Lo, Hi); break;
   case ISD::BUILD_VECTOR:      SplitVecRes_BUILD_VECTOR(N, Lo, Hi); break;
@@ -4523,6 +4525,7 @@ void DAGTypeLegalizer::WidenVectorResult(SDNode *N, unsigned ResNo) {
   case ISD::SELECT_CC:         Res = WidenVecRes_SELECT_CC(N); break;
   case ISD::VP_SETCC:
   case ISD::SETCC:             Res = WidenVecRes_SETCC(N); break;
+  case ISD::POISON:
   case ISD::UNDEF:             Res = WidenVecRes_UNDEF(N); break;
   case ISD::VECTOR_SHUFFLE:
     Res = WidenVecRes_VECTOR_SHUFFLE(cast<ShuffleVectorSDNode>(N));
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 0dfd0302ae5438c..6d62760d25dfeda 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5458,6 +5458,9 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
   case ISD::CopyFromReg:
     return true;
 
+  case ISD::POISON:
+    return false;
+
   case ISD::UNDEF:
     return PoisonOnly;
 
@@ -6307,9 +6310,10 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
         Flags.setNonNeg(N1->getFlags().hasNonNeg());
       return getNode(OpOpcode, DL, VT, N1.getOperand(0), Flags);
     }
-    if (OpOpcode == ISD::UNDEF)
+    if (N1.isUndef())
       // sext(undef) = 0, because the top bits will all be the same.
       return getConstant(0, DL, VT);
+
     break;
   case ISD::ZERO_EXTEND:
     assert(VT.isInteger() && N1.getValueType().isInteger() &&
@@ -6327,7 +6331,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
       Flags.setNonNeg(N1->getFlags().hasNonNeg());
       return getNode(ISD::ZERO_EXTEND, DL, VT, N1.getOperand(0), Flags);
     }
-    if (OpOpcode == ISD::UNDEF)
+    if (N1.isUndef())
       // zext(undef) = 0, because the top bits will be zero.
       return getConstant(0, DL, VT);
 
@@ -6369,7 +6373,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
       // (ext (zext x)) -> (zext x)  and  (ext (sext x)) -> (sext x)
       return getNode(OpOpcode, DL, VT, N1.getOperand(0), Flags);
     }
-    if (OpOpcode == ISD::UNDEF)
+    if (N1.isUndef())
       return getUNDEF(VT);
 
     // (ext (trunc x)) -> x
@@ -6404,7 +6408,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
         return getNode(ISD::TRUNCATE, DL, VT, N1.getOperand(0));
       return N1.getOperand(0);
     }
-    if (OpOpcode == ISD::UNDEF)
+    if (N1.isUndef())
       return getUNDEF(VT);
     if (OpOpcode == ISD::VSCALE && !NewNodesMustHaveLegalTypes)
       return getVScale(DL, VT,
@@ -6422,14 +6426,14 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
     break;
   case ISD::ABS:
     assert(VT.isInteger() && VT == N1.getValueType() && "Invalid ABS!");
-    if (OpOpcode == ISD::UNDEF)
+    if (N1.isUndef())
       return getConstant(0, DL, VT);
     break;
   case ISD::BSWAP:
     assert(VT.isInteger() && VT == N1.getValueType() && "Invalid BSWAP!");
     assert((VT.getScalarSizeInBits() % 16 == 0) &&
            "BSWAP types must be a multiple of 16 bits!");
-    if (OpOpcode == ISD::UNDEF)
+    if (N1.isUndef())
       return getUNDEF(VT);
     // bswap(bswap(X)) -> X.
     if (OpOpcode == ISD::BSWAP)
@@ -6437,7 +6441,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
     break;
   case ISD::BITREVERSE:
     assert(VT.isInteger() && VT == N1.getValueType() && "Invalid BITREVERSE!");
-    if (OpOpcode == ISD::UNDEF)
+    if (N1.isUndef())
       return getUNDEF(VT);
     break;
   case ISD::BITCAST:
@@ -6446,7 +6450,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
     if (VT == N1.getValueType()) return N1;   // noop conversion.
     if (OpOpcode == ISD::BITCAST) // bitconv(bitconv(x)) -> bitconv(x)
       return getNode(ISD::BITCAST, DL, VT, N1.getOperand(0));
-    if (OpOpcode == ISD::UNDEF)
+    if (N1.isUndef())
       return getUNDEF(VT);
     break;
   case ISD::SCALAR_TO_VECTOR:
@@ -6456,7 +6460,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
              N1.getValueType().isInteger() &&
              VT.getVectorElementType().bitsLE(N1.getValueType()))) &&
            "Illegal SCALAR_TO_VECTOR node!");
-    if (OpOpcode == ISD::UNDEF)
+    if (N1.isUndef())
       return getUNDEF(VT);
     // scalar_to_vector(extract_vector_elt V, 0) -> V, top bits are undefined.
     if (OpOpcode == ISD::EXTRACT_VECTOR_ELT &&
@@ -6467,7 +6471,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
     break;
   case ISD::FNEG:
     // Negation of an unknown bag of bits is still completely undefined.
-    if (OpOpcode == ISD::UNDEF)
+    if (N1.isUndef())
       return getUNDEF(VT);
 
     if (OpOpcode == ISD::FNEG) // --X -> X
@@ -9237,6 +9241,11 @@ SDValue SelectionDAG::getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType,
 
   SDVTList VTs = Indexed ?
     getVTList(VT, Ptr.getValueType(), MVT::Other) : getVTList(VT, MVT::Other);
+
+  // Lower poison to undef.
+  if (Ptr.getNode()->isPoison())
+    Ptr = getUNDEF(Ptr.getValueType());
+
   SDValue Ops[] = { Chain, Ptr, Offset };
   FoldingSetNodeID ID;
   AddNodeIDNode(ID, ISD::LOAD, VTs, Ops);
@@ -13374,7 +13383,7 @@ void BuildVectorSDNode::recastRawBits(bool IsLittleEndian,
 bool BuildVectorSDNode::isConstant() const {
   for (const SDValue &Op : op_values()) {
     unsigned Opc = Op.getOpcode();
-    if (Opc != ISD::UNDEF && Opc != ISD::Constant && Opc != ISD::ConstantFP)
+    if (!Op.isUndef() && Opc != ISD::Constant && Opc != ISD::ConstantFP)
       return false;
   }
   return true;
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index f8d7c3ef7bbe71a..fe4e3c00d4260ee 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1819,7 +1819,7 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value *V) {
       return DAG.getConstantFP(*CFP, getCurSDLoc(), VT);
 
     if (isa<UndefValue>(C) && !V->getType()->isAggregateType())
-      return DAG.getUNDEF(VT);
+      return isa<PoisonValue>(C) ? DAG.getPoison(VT) : DAG.getUNDEF(VT);
 
     if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
       visit(CE->getOpcode(), *CE);
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
index 580ff19065557ba..4434b1203451f9e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
@@ -188,6 +188,7 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const {
   case ISD::CopyToReg:                  return "CopyToReg";
   case ISD::CopyFromReg:                return "CopyFromReg";
   case ISD::UNDEF:                      return "undef";
+  case ISD::POISON:                     return "poison";
   case ISD::VSCALE:                     return "vscale";
   case ISD::MERGE_VALUES:               return "merge_values";
   case ISD::INLINEASM:                  return "inlineasm";
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index d64a90bcaae7dac..48fd1e1e4591952 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -3275,6 +3275,7 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
   case ISD::WRITE_REGISTER:
     Select_WRITE_REGISTER(NodeToMatch);
     return;
+  case ISD::POISON:
   case ISD::UNDEF:
     Select_UNDEF(NodeToMatch);
     return;

Copy link

github-actions bot commented Feb 5, 2025

✅ With the latest revision this PR passed the undef deprecator.

Copy link
Contributor

@arsenm arsenm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not NFC

@@ -2783,6 +2785,7 @@ void DAGTypeLegalizer::PromoteFloatResult(SDNode *N, unsigned ResNo) {

case ISD::SINT_TO_FP:
case ISD::UINT_TO_FP: R = PromoteFloatRes_XINT_TO_FP(N); break;
case ISD::POISON:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should get tests that hit all of these legalization paths

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I delete all the case ISD::POISON: in the file since they are not hit by current test case. otherwise the patch will be too big. They will be added in a later patch with new test case.

@dtcxzyw dtcxzyw requested review from RKSimon and bjope February 6, 2025 03:27
@@ -871,7 +871,7 @@ class SelectionDAG {
/// for integers, a type wider than) VT's element type.
SDValue getSplatBuildVector(EVT VT, const SDLoc &DL, SDValue Op) {
// VerifySDNode (via InsertNode) checks BUILD_VECTOR later.
if (Op.getOpcode() == ISD::UNDEF) {
if (Op.isUndef()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be useful to to pull out the isUndef() changes into a real NFC patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it is to isUndefOrPoison(), it is not a NFC now

Copy link
Contributor

@nikic nikic Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the updates isUndef() semantics this comment applies again, it would be good to split off this NFC change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the isUndef() is bool isUndef(bool DoNotIncludeExplicitPoison = false), it is not a NFC, do we still need to split off this NFC change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can introduce the uses of isUndef() without changing the signature.

/// - When UndefOnly is true, returns true only for UNDEF.
/// - When UndefOnly is false, returns true for both UNDEF and POISON.
/// @param UndefOnly Determines whether to check only for UNDEF.
bool isUndef(bool UndefOnly = false) const {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be called something else?
Since we have ISD::UNDEF it would be easy to think that isUndef() checks if the type is ISD::UNDEF. Just like isPoison() checks for ISD::POISON.

Would be clearer to have an isUndefOrPoison helper (or something totally generic not mapping to an ISD type, such as isUndefinedType()) when it isn't a 1-1 mapping to the ISD type name.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it also is easier for downstream targets etc to adapt, if not reusing the old name for something new.

Copy link
Collaborator

@topperc topperc Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we usually want to keep treating poison as undef to avoid updating a bunch of places? In IR, PoisonValue inherits from UndefValue so isa<UndefValue> returns true for poison or undef. I believe SelectionDAGBuilder was previously creating ISD::UNDEF for poison. So continuing to treat ISD::POISON like ISD::UNDEF in many cases would be consistent.

@nikic what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think this should reproduce the IR behavior. isUndef = poison or undef, and places that care specifically about poison check isPoison

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So Poison can be seen as a specialization of Undef.

It felt a bit confusing (terminology wise) to have
isUndef(bool UndefOnly = false)
Since if Poison is a subset of Undef, then setting UndefOnly=true kind of would include Poison as well.

Maybe it should say something like
isUndef(bool DoNotIncludeExplicitPoison = false)
since one wouldn't know if a plain ISD::Undef actually is poison (if Poison is a subset of Undef)?

Copy link
Contributor

@arsenm arsenm Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a bit confusing, but it's internally consistent. But yes, poison is a special more aggressive undef

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that isUndef() should include poison by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the patch based on the discussion.

@diggerlin diggerlin changed the title [NFC ]Introducing a new ISD::POISON SDNode to represent the poison value in the IR. Introducing a new ISD::POISON SDNode to represent the poison value in the IR. Feb 7, 2025
@diggerlin diggerlin requested review from arsenm, bjope and RKSimon February 7, 2025 14:55
@diggerlin
Copy link
Contributor Author

diggerlin commented Feb 11, 2025

gentle ping for feedback.

@diggerlin diggerlin merged commit 8fddef8 into llvm:main Apr 7, 2025
6 of 9 checks passed
kuhar added a commit to iree-org/llvm-project that referenced this pull request Apr 8, 2025
…ent the poison value in the IR. (llvm#125883)"

This reverts commit 8fddef8.

This PR breaks `math_ops_llvm-cpu.mlir` on RISC-V.
@kuhar
Copy link
Member

kuhar commented Apr 8, 2025

Hi @diggerlin,

We've had an assertion failure on RISC-V after integrating this PR:

SoftPromoteHalfResult #0: t26: f16 = poison                                                                                                                    
                                                                                                                                                               
LLVM ERROR: Do not know how to soft promote this operator's result!                                                                                            
Please report issues to https://github.com/iree-org/iree/issues and include the crash backtrace.                                                               
Stack dump:                                                                                                                                                    
0.      Running pass 'Function Pass Manager' on module 'math_ops_llvm_cpu_linked'.                                                                             
1.      Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on function '@_test_rsqrt_f16_dispatch_0_elementwise_63_f16'                              
 #0 0x000076c9b086087e llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/jakub/iree/iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:804:13                                                                                                                                                            
 #1 0x000076c9b085eb35 llvm::sys::RunSignalHandlers() /home/jakub/iree/iree/third_party/llvm-project/llvm/lib/Support/Signals.cpp:106:18                       
 #2 0x000076c9b0860f5a SignalHandler(int, siginfo_t*, void*) /home/jakub/iree/iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:3              
 #3 0x000076c9a9245330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)                                                                                               
 #4 0x000076c9a929eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76                                                                               
 #5 0x000076c9a929eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10                                                                                     
 #6 0x000076c9a929eb2c pthread_kill ./nptl/pthread_kill.c:89:10                                                                                                
 #7 0x000076c9a924527e raise ./signal/../sysdeps/posix/raise.c:27:6                                                                                            
 #8 0x000076c9a92288ff abort ./stdlib/abort.c:81:7                                                                                                             
 #9 0x000076c9b07be3d6 llvm::report_fatal_error(llvm::Twine const&, bool) /home/jakub/iree/iree/third_party/llvm-project/llvm/lib/Support/ErrorHandling.cpp:126:5                                                                                                                                                             
#10 0x000076c9b07be219 (/home/jakub/iree/relass/lib/libIREECompiler.so+0x6dbe219)                                                                              
#11 0x000076c9b6d7c9aa (/home/jakub/iree/relass/lib/libIREECompiler.so+0xd37c9aa)                                                                              
#12 0x000076c9b6db62f7 llvm::DAGTypeLegalizer::run() /home/jakub/iree/iree/third_party/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp:0:9        
#13 0x000076c9b6dba902 llvm::SelectionDAG::LegalizeTypes() /home/jakub/iree/iree/third_party/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp:1060:34                                                                                                                                                             
#14 0x000076c9b6ef3716 llvm::SelectionDAGISel::CodeGenAndEmitDAG() /home/jakub/iree/iree/third_party/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:979:23                                                                                                                                                   
#15 0x000076c9b6ef25fa llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /home/jakub/iree/iree/third_party/llvm-project/llvm/lib/CodeGen/Sele
ctionDAG/SelectionDAGISel.cpp:1649:8                                                                                                                           
#16 0x000076c9b6eefc2f llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/jakub/iree/iree/third_party/llvm-project/llvm/lib/CodeGen/Sel
ectionDAG/SelectionDAGISel.cpp:0:3

kuhar added a commit to iree-org/iree that referenced this pull request Apr 8, 2025
The changes are caused by:
* llvm/llvm-project#134206

Reverts:
* llvm/llvm-project#125883. This breaks the
RISC-V test: `e2e/math/math_ops_llvm-cpu.mlir`.

---------

Signed-off-by: Jakub Kuderski <jakub@nod-labs.com>
kuhar added a commit to iree-org/llvm-project that referenced this pull request Apr 8, 2025
…ent the poison value in the IR. (llvm#125883)"

This reverts commit 8fddef8.

This PR breaks `math_ops_llvm-cpu.mlir` on RISC-V.
kuhar added a commit to iree-org/iree that referenced this pull request Apr 9, 2025
Still carrying the revert for:
* llvm/llvm-project#125883 from #20494

Signed-off-by: Jakub Kuderski <jakub@nod-labs.com>
@mikaelholmen
Copy link
Collaborator

This crashes with this patch:
llc -mtriple=riscv32 bbi-106007_riscv.ll -o /dev/null
It fails like:

SoftenFloatResult #0: t3: f64 = poison

LLVM ERROR: Do not know how to soften the result of this operator!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: build-all/bin/llc -mtriple=riscv32 bbi-106007_riscv.ll -o /dev/null
1.	Running pass 'Function Pass Manager' on module 'bbi-106007_riscv.ll'.
2.	Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on function '@b'
 #0 0x0000560f739d8e86 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (build-all/bin/llc+0x7552e86)
 #1 0x0000560f739d696e llvm::sys::RunSignalHandlers() (build-all/bin/llc+0x755096e)
 #2 0x0000560f739d9549 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007fdbd7461d10 __restore_rt (/lib64/libpthread.so.0+0x12d10)
 #4 0x00007fdbd4e0152f raise (/lib64/libc.so.6+0x4e52f)
 #5 0x00007fdbd4dd4e65 abort (/lib64/libc.so.6+0x21e65)
 #6 0x0000560f7393c863 llvm::report_fatal_error(llvm::Twine const&, bool) (build-all/bin/llc+0x74b6863)
 #7 0x0000560f7393c696 (build-all/bin/llc+0x74b6696)
 #8 0x0000560f73851e80 llvm::DAGTypeLegalizer::SoftenFloatRes_EXTRACT_ELEMENT(llvm::SDNode*) LegalizeFloatTypes.cpp:0:0
 #9 0x0000560f737c650b llvm::DAGTypeLegalizer::run() LegalizeTypes.cpp:0:0
#10 0x0000560f737cbf86 llvm::SelectionDAG::LegalizeTypes() (build-all/bin/llc+0x7345f86)
#11 0x0000560f737b1d68 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (build-all/bin/llc+0x732bd68)
#12 0x0000560f737b0672 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (build-all/bin/llc+0x732a672)
#13 0x0000560f737ada31 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (build-all/bin/llc+0x7327a31)
#14 0x0000560f737ab229 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (build-all/bin/llc+0x7325229)
#15 0x0000560f72a30b87 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (build-all/bin/llc+0x65aab87)
#16 0x0000560f72f7bfe9 llvm::FPPassManager::runOnFunction(llvm::Function&) (build-all/bin/llc+0x6af5fe9)
#17 0x0000560f72f845e2 llvm::FPPassManager::runOnModule(llvm::Module&) (build-all/bin/llc+0x6afe5e2)
#18 0x0000560f72f7cac8 llvm::legacy::PassManagerImpl::run(llvm::Module&) (build-all/bin/llc+0x6af6ac8)
#19 0x0000560f70a3221d compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#20 0x0000560f70a2f900 main (build-all/bin/llc+0x45a9900)
#21 0x00007fdbd4ded7e5 __libc_start_main (/lib64/libc.so.6+0x3a7e5)
#22 0x0000560f70a2ed6e _start (build-all/bin/llc+0x45a8d6e)
Abort (core dumped)

bbi-106007_riscv.ll.gz

@diggerlin
Copy link
Contributor Author

diggerlin commented Apr 9, 2025

there is a quick fix of the assert

diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
index 5ed83060e150..6493e0e6583f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
@@ -165,6 +165,7 @@ void DAGTypeLegalizer::SoftenFloatResult(SDNode *N, unsigned ResNo) {
     case ISD::STRICT_UINT_TO_FP:
     case ISD::SINT_TO_FP:
     case ISD::UINT_TO_FP:  R = SoftenFloatRes_XINT_TO_FP(N); break;
+    case ISD::POISON:
     case ISD::UNDEF:       R = SoftenFloatRes_UNDEF(N); break;
     case ISD::VAARG:       R = SoftenFloatRes_VAARG(N); break;

@kuhar
Copy link
Member

kuhar commented Apr 9, 2025

@diggerlin can we land a fix quickly or should we revert this PR?

can we land a fix quickly or should we revert this PR?

@kuhar
Copy link
Member

kuhar commented Apr 9, 2025

I will create a fix PR with your test case, after the fix PR approved, I revert your revert of this PR before I land the fix PR. iIs it OK ?

I don't understand... Do you want to revert this PR or not?

@diggerlin
Copy link
Contributor Author

I will create a fix PR with your test case, after the fix PR approved, I revert your revert of this PR before I land the fix PR. iIs it OK ?

I don't understand... Do you want to revert this PR or not?

I think you have reverted this PR (36cb81cced6c) . we need to revert your revert first, is it correct ?

@kuhar
Copy link
Member

kuhar commented Apr 9, 2025

I have not -- my revert was only in a downstream fork.

@diggerlin
Copy link
Contributor Author

I created a fix PR as #135056

@kuhar
Copy link
Member

kuhar commented Apr 9, 2025

The fix doesn't resolve my crash -- I'm going to revert this for the time being.

kuhar added a commit that referenced this pull request Apr 9, 2025
…ent the poison value in the IR." (#135060)

Reverts #125883

This PR causes crashes in RISC-V codegen around f16/f64 poison values:
#125883 (comment)
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Apr 9, 2025
…e to represent the poison value in the IR." (#135060)

Reverts llvm/llvm-project#125883

This PR causes crashes in RISC-V codegen around f16/f64 poison values:
llvm/llvm-project#125883 (comment)
AllinLeeYL pushed a commit to AllinLeeYL/llvm-project that referenced this pull request Apr 10, 2025
…ent the poison value in the IR." (llvm#135060)

Reverts llvm#125883

This PR causes crashes in RISC-V codegen around f16/f64 poison values:
llvm#125883 (comment)
diggerlin added a commit to diggerlin/llvm-project that referenced this pull request Apr 10, 2025
…poison value in the IR. (llvm#125883)

A new ISD::POISON SDNode is introduced to represent the `poison value`
in the IR, replacing the previous use of ISD::UNDEF.
var-const pushed a commit to ldionne/llvm-project that referenced this pull request Apr 17, 2025
…ent the poison value in the IR." (llvm#135060)

Reverts llvm#125883

This PR causes crashes in RISC-V codegen around f16/f64 poison values:
llvm#125883 (comment)
diggerlin added a commit that referenced this pull request Apr 17, 2025
…nput is poison. (#135387)

Propagation to poison in function `SDValue
SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,SDValue
N1, SDValue N2, const SDNodeFlags Flags) ` if one of the input is
poison.
 
 The patch also revert the test cases
 llvm/test/CodeGen/X86/pr119158.ll
 llvm/test/CodeGen/X86/half.ll
 
which are mentioned in
#125883 (comment)

---------

Co-authored-by: Amy Kwan <amy.kwan1@ibm.com>
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Apr 17, 2025
…ds if the input is poison. (#135387)

Propagation to poison in function `SDValue
SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,SDValue
N1, SDValue N2, const SDNodeFlags Flags) ` if one of the input is
poison.

 The patch also revert the test cases
 llvm/test/CodeGen/X86/pr119158.ll
 llvm/test/CodeGen/X86/half.ll

which are mentioned in
llvm/llvm-project#125883 (comment)

---------

Co-authored-by: Amy Kwan <amy.kwan1@ibm.com>
qiaojbao pushed a commit to GPUOpen-Drivers/llvm-project that referenced this pull request Apr 29, 2025
Local branch origin/amd-gfx 2a16854 Merged main:9fe6f6a0d430 into origin/amd-gfx:3be6366ceae6
Remote branch main 8fddef8 [SelectionDAG] Introducing a new ISD::POISON SDNode to represent the poison value in the IR. (llvm#125883)
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
…nput is poison. (llvm#135387)

Propagation to poison in function `SDValue
SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,SDValue
N1, SDValue N2, const SDNodeFlags Flags) ` if one of the input is
poison.
 
 The patch also revert the test cases
 llvm/test/CodeGen/X86/pr119158.ll
 llvm/test/CodeGen/X86/half.ll
 
which are mentioned in
llvm#125883 (comment)

---------

Co-authored-by: Amy Kwan <amy.kwan1@ibm.com>
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
…nput is poison. (llvm#135387)

Propagation to poison in function `SDValue
SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,SDValue
N1, SDValue N2, const SDNodeFlags Flags) ` if one of the input is
poison.
 
 The patch also revert the test cases
 llvm/test/CodeGen/X86/pr119158.ll
 llvm/test/CodeGen/X86/half.ll
 
which are mentioned in
llvm#125883 (comment)

---------

Co-authored-by: Amy Kwan <amy.kwan1@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants