[llvm] r342095 - [DAGCombiner] improve formatting for select+setcc code; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 12 16:03:50 PDT 2018
Author: spatel
Date: Wed Sep 12 16:03:50 2018
New Revision: 342095
URL: http://llvm.org/viewvc/llvm-project?rev=342095&view=rev
Log:
[DAGCombiner] improve formatting for select+setcc code; NFC
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=342095&r1=342094&r2=342095&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Wed Sep 12 16:03:50 2018
@@ -7307,27 +7307,25 @@ SDValue DAGCombiner::visitSELECT(SDNode
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);
}
More information about the llvm-commits
mailing list