[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:36 PDT 2025
================
@@ -7573,15 +7573,18 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
} else {
switch (Opcode) {
case ISD::SUB:
- return getUNDEF(VT); // fold op(undef, arg2) -> undef
+ // fold op(undef, arg2) -> undef, fold op(poison, arg2) ->poison.
+ return N1.getOpcode() == ISD::POISON ? getPOISON(VT) : getUNDEF(VT);
case ISD::SIGN_EXTEND_INREG:
case ISD::UDIV:
case ISD::SDIV:
case ISD::UREM:
case ISD::SREM:
case ISD::SSUBSAT:
case ISD::USUBSAT:
- return getConstant(0, DL, VT); // fold op(undef, arg2) -> 0
+ // fold op(undef, arg2) -> 0, fold op(poison, arg2) ->poison.
----------------
amy-kwan wrote:
Comment nit.
```suggestion
// fold op(undef, arg2) -> 0, fold op(poison, arg2) -> poison.
```
https://github.com/llvm/llvm-project/pull/135387
More information about the llvm-commits
mailing list