[llvm] [LLVM][SelectionDAG] Add poison/undef folds for signed/unsigned max/min. (PR #149334)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 18 04:33:42 PDT 2025
================
@@ -7875,13 +7875,22 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
// Fold a bunch of operators when the RHS is undef.
if (N2.isUndef()) {
- switch (Opcode) {
- case ISD::XOR:
- if (N1.isUndef())
+ if (N1.isUndef()) {
+ switch (Opcode) {
+ case ISD::XOR:
// Handle undef ^ undef -> 0 special case. This is a common
// idiom (misuse).
return getConstant(0, DL, VT);
- [[fallthrough]];
+ case ISD::SMAX:
+ case ISD::SMIN:
+ case ISD::UMAX:
+ case ISD::UMIN:
+ return N2.getOpcode() == ISD::POISON ? getPOISON(VT) : getUNDEF(VT);
----------------
arsenm wrote:
This is equivalent to just returning N2?
https://github.com/llvm/llvm-project/pull/149334
More information about the llvm-commits
mailing list