@@ -5465,6 +5465,9 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
54655465 case ISD::CopyFromReg:
54665466 return true;
54675467
5468+ case ISD::POISON:
5469+ return false;
5470+
54685471 case ISD::UNDEF:
54695472 return PoisonOnly;
54705473
@@ -6314,9 +6317,10 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
63146317 Flags.setNonNeg(N1->getFlags().hasNonNeg());
63156318 return getNode(OpOpcode, DL, VT, N1.getOperand(0), Flags);
63166319 }
6317- if (OpOpcode == ISD::UNDEF )
6320+ if (N1.isUndef() )
63186321 // sext(undef) = 0, because the top bits will all be the same.
63196322 return getConstant(0, DL, VT);
6323+
63206324 break;
63216325 case ISD::ZERO_EXTEND:
63226326 assert(VT.isInteger() && N1.getValueType().isInteger() &&
@@ -6334,7 +6338,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
63346338 Flags.setNonNeg(N1->getFlags().hasNonNeg());
63356339 return getNode(ISD::ZERO_EXTEND, DL, VT, N1.getOperand(0), Flags);
63366340 }
6337- if (OpOpcode == ISD::UNDEF )
6341+ if (N1.isUndef() )
63386342 // zext(undef) = 0, because the top bits will be zero.
63396343 return getConstant(0, DL, VT);
63406344
@@ -6376,7 +6380,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
63766380 // (ext (zext x)) -> (zext x) and (ext (sext x)) -> (sext x)
63776381 return getNode(OpOpcode, DL, VT, N1.getOperand(0), Flags);
63786382 }
6379- if (OpOpcode == ISD::UNDEF )
6383+ if (N1.isUndef() )
63806384 return getUNDEF(VT);
63816385
63826386 // (ext (trunc x)) -> x
@@ -6411,7 +6415,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
64116415 return getNode(ISD::TRUNCATE, DL, VT, N1.getOperand(0));
64126416 return N1.getOperand(0);
64136417 }
6414- if (OpOpcode == ISD::UNDEF )
6418+ if (N1.isUndef() )
64156419 return getUNDEF(VT);
64166420 if (OpOpcode == ISD::VSCALE && !NewNodesMustHaveLegalTypes)
64176421 return getVScale(DL, VT,
@@ -6429,22 +6433,22 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
64296433 break;
64306434 case ISD::ABS:
64316435 assert(VT.isInteger() && VT == N1.getValueType() && "Invalid ABS!");
6432- if (OpOpcode == ISD::UNDEF )
6436+ if (N1.isUndef() )
64336437 return getConstant(0, DL, VT);
64346438 break;
64356439 case ISD::BSWAP:
64366440 assert(VT.isInteger() && VT == N1.getValueType() && "Invalid BSWAP!");
64376441 assert((VT.getScalarSizeInBits() % 16 == 0) &&
64386442 "BSWAP types must be a multiple of 16 bits!");
6439- if (OpOpcode == ISD::UNDEF )
6443+ if (N1.isUndef() )
64406444 return getUNDEF(VT);
64416445 // bswap(bswap(X)) -> X.
64426446 if (OpOpcode == ISD::BSWAP)
64436447 return N1.getOperand(0);
64446448 break;
64456449 case ISD::BITREVERSE:
64466450 assert(VT.isInteger() && VT == N1.getValueType() && "Invalid BITREVERSE!");
6447- if (OpOpcode == ISD::UNDEF )
6451+ if (N1.isUndef() )
64486452 return getUNDEF(VT);
64496453 break;
64506454 case ISD::BITCAST:
@@ -6453,7 +6457,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
64536457 if (VT == N1.getValueType()) return N1; // noop conversion.
64546458 if (OpOpcode == ISD::BITCAST) // bitconv(bitconv(x)) -> bitconv(x)
64556459 return getNode(ISD::BITCAST, DL, VT, N1.getOperand(0));
6456- if (OpOpcode == ISD::UNDEF )
6460+ if (N1.isUndef() )
64576461 return getUNDEF(VT);
64586462 break;
64596463 case ISD::SCALAR_TO_VECTOR:
@@ -6463,7 +6467,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
64636467 N1.getValueType().isInteger() &&
64646468 VT.getVectorElementType().bitsLE(N1.getValueType()))) &&
64656469 "Illegal SCALAR_TO_VECTOR node!");
6466- if (OpOpcode == ISD::UNDEF )
6470+ if (N1.isUndef() )
64676471 return getUNDEF(VT);
64686472 // scalar_to_vector(extract_vector_elt V, 0) -> V, top bits are undefined.
64696473 if (OpOpcode == ISD::EXTRACT_VECTOR_ELT &&
@@ -6474,7 +6478,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
64746478 break;
64756479 case ISD::FNEG:
64766480 // Negation of an unknown bag of bits is still completely undefined.
6477- if (OpOpcode == ISD::UNDEF )
6481+ if (N1.isUndef() )
64786482 return getUNDEF(VT);
64796483
64806484 if (OpOpcode == ISD::FNEG) // --X -> X
@@ -9244,6 +9248,11 @@ SDValue SelectionDAG::getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType,
92449248
92459249 SDVTList VTs = Indexed ?
92469250 getVTList(VT, Ptr.getValueType(), MVT::Other) : getVTList(VT, MVT::Other);
9251+
9252+ // Lower poison to undef.
9253+ if (Ptr.getNode()->isPoison())
9254+ Ptr = getUNDEF(Ptr.getValueType());
9255+
92479256 SDValue Ops[] = { Chain, Ptr, Offset };
92489257 FoldingSetNodeID ID;
92499258 AddNodeIDNode(ID, ISD::LOAD, VTs, Ops);
@@ -13380,7 +13389,7 @@ void BuildVectorSDNode::recastRawBits(bool IsLittleEndian,
1338013389bool BuildVectorSDNode::isConstant() const {
1338113390 for (const SDValue &Op : op_values()) {
1338213391 unsigned Opc = Op.getOpcode();
13383- if (Opc != ISD::UNDEF && Opc != ISD::Constant && Opc != ISD::ConstantFP)
13392+ if (!Op.isUndef() && Opc != ISD::Constant && Opc != ISD::ConstantFP)
1338413393 return false;
1338513394 }
1338613395 return true;
0 commit comments