[DAGCombiner] improve formatting for select+setcc code; NFC
llvm-svn: 342095
This commit is contained in:
parent
9a45452987
commit
8a478b79dc
|
@ -7307,27 +7307,25 @@ SDValue DAGCombiner::visitSELECT(SDNode *N) {
|
||||||
return DAG.getNode(ISD::SELECT, DL, VT, N0->getOperand(0), N2, N1);
|
return DAG.getNode(ISD::SELECT, DL, VT, N0->getOperand(0), N2, N1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fold selects based on a setcc into other things, such as min/max/abs
|
// Fold selects based on a setcc into other things, such as min/max/abs.
|
||||||
if (N0.getOpcode() == ISD::SETCC) {
|
if (N0.getOpcode() == ISD::SETCC) {
|
||||||
// select x, y (fcmp lt x, y) -> fminnum x, y
|
SDValue Cond0 = N0.getOperand(0), Cond1 = N0.getOperand(1);
|
||||||
// select x, y (fcmp gt x, y) -> fmaxnum x, y
|
ISD::CondCode CC = cast<CondCodeSDNode>(N0.getOperand(2))->get();
|
||||||
//
|
|
||||||
// This is OK if we don't care about what happens if either operand is a
|
|
||||||
// NaN.
|
|
||||||
//
|
|
||||||
if (N0.hasOneUse() && isLegalToCombineMinNumMaxNum(DAG, N1, N2)) {
|
|
||||||
ISD::CondCode CC = cast<CondCodeSDNode>(N0.getOperand(2))->get();
|
|
||||||
|
|
||||||
if (SDValue FMinMax = combineMinNumMaxNum(
|
// select (fcmp lt x, y), x, y -> fminnum x, y
|
||||||
DL, VT, N0.getOperand(0), N0.getOperand(1), N1, N2, CC, TLI, DAG))
|
// select (fcmp gt x, y), x, y -> fmaxnum x, y
|
||||||
|
//
|
||||||
|
// This is OK if we don't care what happens if either operand is a NaN.
|
||||||
|
if (N0.hasOneUse() && isLegalToCombineMinNumMaxNum(DAG, N1, N2))
|
||||||
|
if (SDValue FMinMax = combineMinNumMaxNum(DL, VT, Cond0, Cond1, N1, N2,
|
||||||
|
CC, TLI, DAG))
|
||||||
return FMinMax;
|
return FMinMax;
|
||||||
}
|
|
||||||
|
|
||||||
if ((!LegalOperations &&
|
if (TLI.isOperationLegal(ISD::SELECT_CC, VT) ||
|
||||||
TLI.isOperationLegalOrCustom(ISD::SELECT_CC, VT)) ||
|
(!LegalOperations && TLI.isOperationLegalOrCustom(ISD::SELECT_CC, VT)))
|
||||||
TLI.isOperationLegal(ISD::SELECT_CC, VT))
|
return DAG.getNode(ISD::SELECT_CC, DL, VT, Cond0, Cond1, N1, N2,
|
||||||
return DAG.getNode(ISD::SELECT_CC, DL, VT, N0.getOperand(0),
|
N0.getOperand(2));
|
||||||
N0.getOperand(1), N1, N2, N0.getOperand(2));
|
|
||||||
return SimplifySelect(DL, N0, N1, N2);
|
return SimplifySelect(DL, N0, N1, N2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue