This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: x86: Emit rsqrt with only -ffast-math


On 11/05/2009 02:57 PM, Michael Matz wrote:
>
>     float sqrt(float r) {
>       float q = rsqrt(r);   // approx. 1.0 / sqrt (r);
>       float y = q * r;      // approx sqrt (r)
>       float e = y * y - r;  // y == sqrt (r + e), with e small
>       return y - e / (2.0 * y); // Newton Raphson correction
>     }

That itself has a division in it, and hence wouldn't be better than just
using the normal sqrt (no recriprocal) instruction.

Yes, that would be


return y - e * q * 0.5;

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]