Use the target-specified iteration count to opt out of any further refinement of an estimate. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218700 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sanjay Patel 2014-09-30 20:44:23 +00:00
parent cafc85bf1e
commit 73a335f7f6

View File

@ -11778,8 +11778,9 @@ SDValue DAGCombiner::BuildReciprocalEstimate(SDValue Op) {
// Expose the DAG combiner to the target combiner implementations. // Expose the DAG combiner to the target combiner implementations.
TargetLowering::DAGCombinerInfo DCI(DAG, Level, false, this); TargetLowering::DAGCombinerInfo DCI(DAG, Level, false, this);
unsigned Iterations; unsigned Iterations = 0;
if (SDValue Est = TLI.getRecipEstimate(Op, DCI, Iterations)) { if (SDValue Est = TLI.getRecipEstimate(Op, DCI, Iterations)) {
if (Iterations) {
// Newton iteration for a function: F(X) is X_{i+1} = X_i - F(X_i)/F'(X_i) // Newton iteration for a function: F(X) is X_{i+1} = X_i - F(X_i)/F'(X_i)
// For the reciprocal, we need to find the zero of the function: // For the reciprocal, we need to find the zero of the function:
// F(X) = A X - 1 [which has a zero at X = 1/A] // F(X) = A X - 1 [which has a zero at X = 1/A]
@ -11806,7 +11807,7 @@ SDValue DAGCombiner::BuildReciprocalEstimate(SDValue Op) {
Est = DAG.getNode(ISD::FADD, DL, VT, Est, NewEst); Est = DAG.getNode(ISD::FADD, DL, VT, Est, NewEst);
AddToWorklist(Est.getNode()); AddToWorklist(Est.getNode());
} }
}
return Est; return Est;
} }
@ -11819,8 +11820,9 @@ SDValue DAGCombiner::BuildRsqrtEstimate(SDValue Op) {
// Expose the DAG combiner to the target combiner implementations. // Expose the DAG combiner to the target combiner implementations.
TargetLowering::DAGCombinerInfo DCI(DAG, Level, false, this); TargetLowering::DAGCombinerInfo DCI(DAG, Level, false, this);
unsigned Iterations; unsigned Iterations = 0;
if (SDValue Est = TLI.getRsqrtEstimate(Op, DCI, Iterations)) { if (SDValue Est = TLI.getRsqrtEstimate(Op, DCI, Iterations)) {
if (Iterations) {
// Newton iteration for a function: F(X) is X_{i+1} = X_i - F(X_i)/F'(X_i) // Newton iteration for a function: F(X) is X_{i+1} = X_i - F(X_i)/F'(X_i)
// For the reciprocal sqrt, we need to find the zero of the function: // For the reciprocal sqrt, we need to find the zero of the function:
// F(X) = 1/X^2 - A [which has a zero at X = 1/sqrt(A)] // F(X) = 1/X^2 - A [which has a zero at X = 1/sqrt(A)]
@ -11855,7 +11857,7 @@ SDValue DAGCombiner::BuildRsqrtEstimate(SDValue Op) {
Est = DAG.getNode(ISD::FMUL, DL, VT, Est, NewEst); Est = DAG.getNode(ISD::FMUL, DL, VT, Est, NewEst);
AddToWorklist(Est.getNode()); AddToWorklist(Est.getNode());
} }
}
return Est; return Est;
} }