[llvm] [SelectionDAG] Propagate poison in getNode with two operands if the input is poison. (PR #135387)
Amy Kwan via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 16 10:31:37 PDT 2025
================
@@ -7601,16 +7604,20 @@ 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)
+ : getConstant(0, DL, VT);
case ISD::OR:
case ISD::SADDSAT:
case ISD::UADDSAT:
- return getAllOnesConstant(DL, VT);
+ return N2.getOpcode() == ISD::POISON ? getPOISON(VT)
----------------
amy-kwan wrote:
Nit: maybe we can add a similar comment, like the other cases?
https://github.com/llvm/llvm-project/pull/135387
More information about the llvm-commits
mailing list