Now why is the x87(or slightly modified) assembly routine not used also for the x86_64?
--- Begin Message ---
- To: "Ashwani Bhat" <ashwanib@xxxxxxxxxxx>
- Subject: Re: Help Needed for gcc on Linux x86_64
- From: Andrew Haley <aph@xxxxxxxxxx>
- Date: Thu, 18 May 2006 14:24:25 +0100
- Cc: <gcc-help@xxxxxxxxxxx>
- In-reply-to: <654233C4E6B967499EE923549F2D137C020AB44B@xxxxxxxxxxxxxxxxxxxxxxxxx>
- References: <654233C4E6B967499EE923549F2D137C020AB44B@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Sender: gcc-help-owner@xxxxxxxxxxx
Ashwani Bhat writes: > On Linux 64 bit platform, gcc shows poor performance for pow() function > when the first argument is very close to 1. To reproduce the issue, just > create a simple c file case.c > > Contents of case.c > ================== > #include <stdio.h> > #include <math.h> > > int main(){ > double x; > int i; > for( i=1; i<10000; i++ ) { > x = pow( 1.0000000000000002, 1.5 ); > } > printf( "x = %1.30f\n", x ); > } > > then compile it > % gcc -lm -m64 case.c -o case > % ./case > > Notes > 1. gcc option -ffast-math does not help here > 2. if compiled with "-m32" instead of "-m64", then the calculation is > fast. > > Can you please help me here .. I have tried it with gcc -v3.2.3, 3.4.2, > 4.1.0. But results are same. Interesting. The case you have found is one where on the x86_64 libm calls a special routine (amusingly? called __slowpow) which does the whole calculation using multi-precision doubles. This routine is only called in the rare case where the standard routines aren't accurate enough to obtain a correctly rounded result. In the x87 case, there is a special assembly-langauge version of __ieee754_pow. This takes advantage of the extended precision in the x87, so it doesn't need to call __slowpow. Andrew.
--- End Message ---
Attachment:
signature.asc
Description: This is a digitally signed message part