Skip to content

Commit 48bd6a0

Browse files
committed
[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.
1 parent e5edd64 commit 48bd6a0

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4321,26 +4321,24 @@ SDValue DAGCombiner::visitIMINMAX(SDNode *N) {
43214321
SDValue N0 = N->getOperand(0);
43224322
SDValue N1 = N->getOperand(1);
43234323
EVT VT = N0.getValueType();
4324+
unsigned Opcode = N->getOpcode();
43244325

43254326
// fold vector ops
43264327
if (VT.isVector())
43274328
if (SDValue FoldedVOp = SimplifyVBinOp(N))
43284329
return FoldedVOp;
43294330

43304331
// fold operation with constant operands.
4331-
ConstantSDNode *N0C = getAsNonOpaqueConstant(N0);
4332-
ConstantSDNode *N1C = getAsNonOpaqueConstant(N1);
4333-
if (N0C && N1C)
4334-
return DAG.FoldConstantArithmetic(N->getOpcode(), SDLoc(N), VT, N0C, N1C);
4332+
if (SDValue C = DAG.FoldConstantArithmetic(Opcode, SDLoc(N), VT, {N0, N1}))
4333+
return C;
43354334

43364335
// canonicalize constant to RHS
43374336
if (DAG.isConstantIntBuildVectorOrConstantInt(N0) &&
4338-
!DAG.isConstantIntBuildVectorOrConstantInt(N1))
4337+
!DAG.isConstantIntBuildVectorOrConstantInt(N1))
43394338
return DAG.getNode(N->getOpcode(), SDLoc(N), VT, N1, N0);
43404339

43414340
// Is sign bits are zero, flip between UMIN/UMAX and SMIN/SMAX.
43424341
// Only do this if the current op isn't legal and the flipped is.
4343-
unsigned Opcode = N->getOpcode();
43444342
if (!TLI.isOperationLegal(Opcode, VT) &&
43454343
(N0.isUndef() || DAG.SignBitIsZero(N0)) &&
43464344
(N1.isUndef() || DAG.SignBitIsZero(N1))) {

0 commit comments

Comments
 (0)