diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2018-09-12 23:03:50 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2018-09-12 23:03:50 +0000 |
| commit | 8a478b79dc906c1f737d78fec2431dd58de646cc (patch) | |
| tree | 03604b064bd99d83f64ab3b82855b2570dda478e /llvm/lib/CodeGen | |
| parent | 9a45452987eb1a6d8a2fcf891e4ba17951c97436 (diff) | |
| download | bcm5719-llvm-8a478b79dc906c1f737d78fec2431dd58de646cc.tar.gz bcm5719-llvm-8a478b79dc906c1f737d78fec2431dd58de646cc.zip | |
[DAGCombiner] improve formatting for select+setcc code; NFC
llvm-svn: 342095
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index c7b02769471..20e749ba569 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -7307,27 +7307,25 @@ SDValue DAGCombiner::visitSELECT(SDNode *N) { 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) { - // select x, y (fcmp lt x, y) -> fminnum x, y - // select x, y (fcmp gt x, y) -> fmaxnum x, y - // - // 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(); + SDValue Cond0 = N0.getOperand(0), Cond1 = N0.getOperand(1); + ISD::CondCode CC = cast<CondCodeSDNode>(N0.getOperand(2))->get(); - if (SDValue FMinMax = combineMinNumMaxNum( - DL, VT, N0.getOperand(0), N0.getOperand(1), N1, N2, CC, TLI, DAG)) + // select (fcmp lt x, y), x, y -> fminnum x, y + // 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; - } - if ((!LegalOperations && - TLI.isOperationLegalOrCustom(ISD::SELECT_CC, VT)) || - TLI.isOperationLegal(ISD::SELECT_CC, VT)) - return DAG.getNode(ISD::SELECT_CC, DL, VT, N0.getOperand(0), - N0.getOperand(1), N1, N2, N0.getOperand(2)); + if (TLI.isOperationLegal(ISD::SELECT_CC, VT) || + (!LegalOperations && TLI.isOperationLegalOrCustom(ISD::SELECT_CC, VT))) + return DAG.getNode(ISD::SELECT_CC, DL, VT, Cond0, Cond1, N1, N2, + N0.getOperand(2)); + return SimplifySelect(DL, N0, N1, N2); } |

