[llvm] [SelectionDAG] Propagate poison in getNode with two operands if the second is poison. (PR #135387)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 12 03:29:38 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)
----------------
arsenm wrote:

Can return N2 instead of returning doing a new getPOISON 

https://github.com/llvm/llvm-project/pull/135387


More information about the llvm-commits mailing list