Commit 48bd6a09 authored by Simon Pilgrim's avatar Simon Pilgrim
Browse files

[DAGCombiner] visitIMINMAX - use general SelectionDAG::FoldConstantArithmetic

This handles all the constant splat / opaque testing for us instead of the ConstantSDNode variant where we have to do it ourselves.
parent e5edd641
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -4321,6 +4321,7 @@ SDValue DAGCombiner::visitIMINMAX(SDNode *N) {
  SDValue N0 = N->getOperand(0);
  SDValue N1 = N->getOperand(1);
  EVT VT = N0.getValueType();
  unsigned Opcode = N->getOpcode();
  // fold vector ops
  if (VT.isVector())
@@ -4328,10 +4329,8 @@ SDValue DAGCombiner::visitIMINMAX(SDNode *N) {
      return FoldedVOp;
  // fold operation with constant operands.
  ConstantSDNode *N0C = getAsNonOpaqueConstant(N0);
  ConstantSDNode *N1C = getAsNonOpaqueConstant(N1);
  if (N0C && N1C)
    return DAG.FoldConstantArithmetic(N->getOpcode(), SDLoc(N), VT, N0C, N1C);
  if (SDValue C = DAG.FoldConstantArithmetic(Opcode, SDLoc(N), VT, {N0, N1}))
    return C;
  // canonicalize constant to RHS
  if (DAG.isConstantIntBuildVectorOrConstantInt(N0) &&
@@ -4340,7 +4339,6 @@ SDValue DAGCombiner::visitIMINMAX(SDNode *N) {
  // Is sign bits are zero, flip between UMIN/UMAX and SMIN/SMAX.
  // Only do this if the current op isn't legal and the flipped is.
  unsigned Opcode = N->getOpcode();
  if (!TLI.isOperationLegal(Opcode, VT) &&
      (N0.isUndef() || DAG.SignBitIsZero(N0)) &&
      (N1.isUndef() || DAG.SignBitIsZero(N1))) {