This is the mail archive of the gcc@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]

optimisation problem with sqrt


Hello,

I have a problem when optimising a simple c program with gcc (version
2.95.2) using sqrt function.

Here is the program:

/* file test.c */
int main()
{
 int i;
 double x;
 for (i = 0; i < 200000000; ++i) x = sqrt(2.0);
 printf("Finished ; i = %d ; x = %lf\n", i, x);
 return 0;
}

/* end */

command for compiling:

# gcc -O2 -ffast-math test.c
# time ./a.out

It takes approximatly 22 seconds to run on a Pentium III (600 MHz).  I
have been very
surprised since on my less efficient Celeron (466 MHz), I made a similar

test which takes
significantly less time (I think 40 times faster) with the same version
of gcc.

Some further informations on my system:

I decided to compile the kernel 2.3.99pre6 on a Celeron to use it on my
current PIII.
Furthermore, I use the same hard disk of my old Celeron (so the same OS
and environnement)
on my Pentium III - I installed a Mandrake 7.0 (kernel 2.2.14
originaly).

With another Pentium III (500 MHz) with gcc 2.7.2.3, the test takes 1.03

sec.

A last element : when asking for assembler output, the instruction
'fsqrt' always appears
(Even on my PIII 600).  That's why I'm very puzzled.

Does someone can help me understand the problem ?

    Thank you for any help.


Sylvain Zimmermann




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