Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit ea64a51

Browse files
committed
early exits -> less indenting; NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241716 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent a307401 commit ea64a51

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8406,30 +8406,29 @@ SDValue DAGCombiner::visitFREM(SDNode *N) {
84068406
}
84078407

84088408
SDValue DAGCombiner::visitFSQRT(SDNode *N) {
8409-
if (DAG.getTarget().Options.UnsafeFPMath &&
8410-
!TLI.isFsqrtCheap()) {
8411-
// Compute this as X * (1/sqrt(X)) = X * (X ** -0.5)
8412-
if (SDValue RV = BuildRsqrtEstimate(N->getOperand(0))) {
8413-
EVT VT = RV.getValueType();
8414-
SDLoc DL(N);
8415-
RV = DAG.getNode(ISD::FMUL, DL, VT, N->getOperand(0), RV);
8416-
AddToWorklist(RV.getNode());
8417-
8418-
// Unfortunately, RV is now NaN if the input was exactly 0.
8419-
// Select out this case and force the answer to 0.
8420-
SDValue Zero = DAG.getConstantFP(0.0, DL, VT);
8421-
SDValue ZeroCmp =
8422-
DAG.getSetCC(DL, TLI.getSetCCResultType(*DAG.getContext(), VT),
8423-
N->getOperand(0), Zero, ISD::SETEQ);
8424-
AddToWorklist(ZeroCmp.getNode());
8425-
AddToWorklist(RV.getNode());
8409+
if (!DAG.getTarget().Options.UnsafeFPMath || TLI.isFsqrtCheap())
8410+
return SDValue();
84268411

8427-
RV = DAG.getNode(VT.isVector() ? ISD::VSELECT : ISD::SELECT,
8428-
DL, VT, ZeroCmp, Zero, RV);
8429-
return RV;
8430-
}
8431-
}
8432-
return SDValue();
8412+
// Compute this as X * (1/sqrt(X)) = X * (X ** -0.5)
8413+
SDValue RV = BuildRsqrtEstimate(N->getOperand(0));
8414+
if (!RV)
8415+
return SDValue();
8416+
8417+
EVT VT = RV.getValueType();
8418+
SDLoc DL(N);
8419+
RV = DAG.getNode(ISD::FMUL, DL, VT, N->getOperand(0), RV);
8420+
AddToWorklist(RV.getNode());
8421+
8422+
// Unfortunately, RV is now NaN if the input was exactly 0.
8423+
// Select out this case and force the answer to 0.
8424+
SDValue Zero = DAG.getConstantFP(0.0, DL, VT);
8425+
EVT CCVT = TLI.getSetCCResultType(*DAG.getContext(), VT);
8426+
SDValue ZeroCmp = DAG.getSetCC(DL, CCVT, N->getOperand(0), Zero, ISD::SETEQ);
8427+
AddToWorklist(ZeroCmp.getNode());
8428+
AddToWorklist(RV.getNode());
8429+
8430+
return DAG.getNode(VT.isVector() ? ISD::VSELECT : ISD::SELECT, DL, VT,
8431+
ZeroCmp, Zero, RV);
84338432
}
84348433

84358434
SDValue DAGCombiner::visitFCOPYSIGN(SDNode *N) {

0 commit comments

Comments
 (0)