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]

Re: optimisation problem with sqrt


If you don't compile with -ffast-math (as implemented in recent
gcc versions), code is generated to check for any exception flag
raised by execution of fsqrt.  That alone is quite time
consuming, possibly it prevents any pipe-lining.  When there is
an exception, the separately compiled sqrt() is executed.  Did
you find a way to present (int)2 rather than (double)2 as an
argument, e.g. by omitting <math.h>?

----- Original Message -----
From: "Sylvain Zimmermann" <Sylvain.Zimmermann@uhp.u-nancy.fr>
To: "Christian Häggström" <97nv46@skola.kiruna.se>
Cc: <gcc@gcc.gnu.org>
Sent: Friday, May 12, 2000 5:49 AM
Subject: Re: optimisation problem with sqrt


>
> Christian Häggström wrote:
>
> > > for (i = 0; i < 200000000; ++i) x = sqrt(2.0);
> >
> > > when asking for assembler output, the instruction 'fsqrt'
always appears
> > > (Even on my PIII 600).  That's why I'm very puzzled.
> >
> > The 'sqrt' function is designed to take a non-constant
argument.
> > Prefer use M_SQRT_2 or similar for constants, defined in
<math.h>.
>
> Ok.  But my goal was just to test my computer performances
that I expected
> better on my Pentium III (600 MHz) than on a Celeron (466
MHz).  I only wanted
> to see the time the processor would take for this loop.
>
> I still don't understand why the 'fsqrt' is used in the
assembler file and it
> seems not beeing used really by the processor itself.  (I'm a
novice in
> assembler.)
>
> I searched in the mailing lists and found lots of emails
related to this
> problem.  But they confuse me.
>
> Maybe the clue is I installed everything on an Celeron and
then, I put the
> hard disk on a Pentium III?  Should I compile gcc on my new
machine?
> Have you any idea from where the problem could come?
>
> Thank you,
> Sylvain Zimmermann
>
>


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