[llvm] [SelectionDAG] Propagate poison in getNode with two operands if the second is poison. (PR #135387)
zhijian lin via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 15 07:56:23 PDT 2025
================
@@ -7601,16 +7601,23 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
case ISD::SDIV:
case ISD::UREM:
case ISD::SREM:
- return getUNDEF(VT); // fold op(arg1, undef) -> undef
+ // fold op(arg1, undef) -> undef, // fold op(arg1, poison) -> poison.
+ return N2.getOpcode() == ISD::POISON
+ ? getPOISON(VT)
+ : getUNDEF(VT);
case ISD::MUL:
case ISD::AND:
case ISD::SSUBSAT:
case ISD::USUBSAT:
- return getConstant(0, DL, VT); // fold op(arg1, undef) -> 0
+ // fold op(arg1, undef) -> 0, fold op(arg1, poison) -> poison.
+ return N2.getOpcode() == ISD::POISON
+ ? getPOISON(VT)
----------------
diggerlin wrote:
I do not think we can guarantee N2.getValueType() is same as VT.
https://github.com/llvm/llvm-project/pull/135387
More information about the llvm-commits
mailing list