Skip to content

Commit 6df483c

Browse files
kuharYilin Li
authored andcommitted
Revert "[SelectionDAG] Introducing a new ISD::POISON SDNode to represent 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)
1 parent 22cca70 commit 6df483c

15 files changed

+38
-73
lines changed

llvm/include/llvm/CodeGen/ISDOpcodes.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,6 @@ enum NodeType {
217217
/// UNDEF - An undefined node.
218218
UNDEF,
219219

220-
/// POISON - A poison node.
221-
POISON,
222-
223220
/// FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or
224221
/// is evaluated to UNDEF), or returns VAL otherwise. Note that each
225222
/// read of UNDEF can yield different value, but FREEZE(UNDEF) cannot.

llvm/include/llvm/CodeGen/SelectionDAG.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,9 +1130,6 @@ class SelectionDAG {
11301130
return getNode(ISD::UNDEF, SDLoc(), VT);
11311131
}
11321132

1133-
/// Return a POISON node. POISON does not have a useful SDLoc.
1134-
SDValue getPOISON(EVT VT) { return getNode(ISD::POISON, SDLoc(), VT); }
1135-
11361133
/// Return a node that represents the runtime scaling 'MulImm * RuntimeVL'.
11371134
SDValue getVScale(const SDLoc &DL, EVT VT, APInt MulImm,
11381135
bool ConstantFold = true);

llvm/include/llvm/CodeGen/SelectionDAGNodes.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,8 @@ END_TWO_BYTE_PACK()
692692
/// \<target\>ISD namespace).
693693
bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
694694

695-
/// Returns true if the node type is UNDEF or POISON.
696-
bool isUndef() const {
697-
return NodeType == ISD::UNDEF || NodeType == ISD::POISON;
698-
}
695+
/// Return true if the type of the node type undefined.
696+
bool isUndef() const { return NodeType == ISD::UNDEF; }
699697

700698
/// Test if this node is a memory intrinsic (with valid pointer information).
701699
bool isMemIntrinsic() const { return SDNodeBits.IsMemIntrinsic; }

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16287,8 +16287,7 @@ SDValue DAGCombiner::visitFREEZE(SDNode *N) {
1628716287
// Finally, recreate the node, it's operands were updated to use
1628816288
// frozen operands, so we just need to use it's "original" operands.
1628916289
SmallVector<SDValue> Ops(N0->ops());
16290-
// TODO: ISD::UNDEF and ISD::POISON should get separate handling, but best
16291-
// leave for a future patch.
16290+
// Special-handle ISD::UNDEF, each single one of them can be it's own thing.
1629216291
for (SDValue &Op : Ops) {
1629316292
if (Op.isUndef())
1629416293
Op = DAG.getFreeze(Op);

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -986,19 +986,6 @@ void SelectionDAGLegalize::LegalizeOp(SDNode *Node) {
986986
TargetLowering::LegalizeAction Action = TargetLowering::Legal;
987987
bool SimpleFinishLegalizing = true;
988988
switch (Node->getOpcode()) {
989-
// TODO: Currently, POISON is being lowered to UNDEF here. However, there is
990-
// an open concern that this transformation may not be ideal, as targets
991-
// should ideally handle POISON directly. Changing this behavior would require
992-
// adding support for POISON in TableGen, which is a large change.
993-
// Additionally, many existing test cases rely on the current behavior (e.g.,
994-
// llvm/test/CodeGen/PowerPC/vec_shuffle.ll). A broader discussion and
995-
// incremental changes might be needed to properly
996-
// support POISON without breaking existing targets and tests.
997-
case ISD::POISON: {
998-
SDValue UndefNode = DAG.getUNDEF(Node->getValueType(0));
999-
ReplaceNode(Node, UndefNode.getNode());
1000-
break;
1001-
}
1002989
case ISD::INTRINSIC_W_CHAIN:
1003990
case ISD::INTRINSIC_WO_CHAIN:
1004991
case ISD::INTRINSIC_VOID:
@@ -3182,7 +3169,6 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
31823169
for (unsigned i = 0; i < Node->getNumValues(); i++)
31833170
Results.push_back(Node->getOperand(i));
31843171
break;
3185-
case ISD::POISON:
31863172
case ISD::UNDEF: {
31873173
EVT VT = Node->getValueType(0);
31883174
if (VT.isInteger())

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2845,7 +2845,6 @@ void DAGTypeLegalizer::PromoteFloatResult(SDNode *N, unsigned ResNo) {
28452845

28462846
case ISD::SINT_TO_FP:
28472847
case ISD::UINT_TO_FP: R = PromoteFloatRes_XINT_TO_FP(N); break;
2848-
case ISD::POISON:
28492848
case ISD::UNDEF: R = PromoteFloatRes_UNDEF(N); break;
28502849
case ISD::ATOMIC_SWAP: R = BitcastToInt_ATOMIC_SWAP(N); break;
28512850
case ISD::VECREDUCE_FADD:

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ void DAGTypeLegalizer::PromoteIntegerResult(SDNode *N, unsigned ResNo) {
118118
case ISD::VP_SRL: Res = PromoteIntRes_SRL(N); break;
119119
case ISD::VP_TRUNCATE:
120120
case ISD::TRUNCATE: Res = PromoteIntRes_TRUNCATE(N); break;
121-
case ISD::POISON:
122121
case ISD::UNDEF: Res = PromoteIntRes_UNDEF(N); break;
123122
case ISD::VAARG: Res = PromoteIntRes_VAARG(N); break;
124123
case ISD::VSCALE: Res = PromoteIntRes_VSCALE(N); break;
@@ -2915,7 +2914,6 @@ void DAGTypeLegalizer::ExpandIntegerResult(SDNode *N, unsigned ResNo) {
29152914
case ISD::MERGE_VALUES: SplitRes_MERGE_VALUES(N, ResNo, Lo, Hi); break;
29162915
case ISD::SELECT: SplitRes_Select(N, Lo, Hi); break;
29172916
case ISD::SELECT_CC: SplitRes_SELECT_CC(N, Lo, Hi); break;
2918-
case ISD::POISON:
29192917
case ISD::UNDEF: SplitRes_UNDEF(N, Lo, Hi); break;
29202918
case ISD::FREEZE: SplitRes_FREEZE(N, Lo, Hi); break;
29212919
case ISD::SETCC: ExpandIntRes_SETCC(N, Lo, Hi); break;

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ void DAGTypeLegalizer::ScalarizeVectorResult(SDNode *N, unsigned ResNo) {
7171
case ISD::SELECT: R = ScalarizeVecRes_SELECT(N); break;
7272
case ISD::SELECT_CC: R = ScalarizeVecRes_SELECT_CC(N); break;
7373
case ISD::SETCC: R = ScalarizeVecRes_SETCC(N); break;
74-
case ISD::POISON:
7574
case ISD::UNDEF: R = ScalarizeVecRes_UNDEF(N); break;
7675
case ISD::VECTOR_SHUFFLE: R = ScalarizeVecRes_VECTOR_SHUFFLE(N); break;
7776
case ISD::IS_FPCLASS: R = ScalarizeVecRes_IS_FPCLASS(N); break;
@@ -1138,7 +1137,6 @@ void DAGTypeLegalizer::SplitVectorResult(SDNode *N, unsigned ResNo) {
11381137
case ISD::VP_MERGE:
11391138
case ISD::VP_SELECT: SplitRes_Select(N, Lo, Hi); break;
11401139
case ISD::SELECT_CC: SplitRes_SELECT_CC(N, Lo, Hi); break;
1141-
case ISD::POISON:
11421140
case ISD::UNDEF: SplitRes_UNDEF(N, Lo, Hi); break;
11431141
case ISD::BITCAST: SplitVecRes_BITCAST(N, Lo, Hi); break;
11441142
case ISD::BUILD_VECTOR: SplitVecRes_BUILD_VECTOR(N, Lo, Hi); break;
@@ -4594,7 +4592,6 @@ void DAGTypeLegalizer::WidenVectorResult(SDNode *N, unsigned ResNo) {
45944592
case ISD::SELECT_CC: Res = WidenVecRes_SELECT_CC(N); break;
45954593
case ISD::VP_SETCC:
45964594
case ISD::SETCC: Res = WidenVecRes_SETCC(N); break;
4597-
case ISD::POISON:
45984595
case ISD::UNDEF: Res = WidenVecRes_UNDEF(N); break;
45994596
case ISD::VECTOR_SHUFFLE:
46004597
Res = WidenVecRes_VECTOR_SHUFFLE(cast<ShuffleVectorSDNode>(N));

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5387,9 +5387,6 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
53875387
case ISD::CopyFromReg:
53885388
return true;
53895389

5390-
case ISD::POISON:
5391-
return false;
5392-
53935390
case ISD::UNDEF:
53945391
return PoisonOnly;
53955392

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,7 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value *V) {
18171817
return DAG.getConstantFP(*CFP, getCurSDLoc(), VT);
18181818

18191819
if (isa<UndefValue>(C) && !V->getType()->isAggregateType())
1820-
return isa<PoisonValue>(C) ? DAG.getPOISON(VT) : DAG.getUNDEF(VT);
1820+
return DAG.getUNDEF(VT);
18211821

18221822
if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
18231823
visit(CE->getOpcode(), *CE);

0 commit comments

Comments
 (0)