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

# GCC 4.0, Fast Math, and Acovea

*From*: Scott Robert Ladd <scott dot ladd at coyotegulch dot com>
*To*: gcc at gcc dot gnu dot org
*Date*: Fri, 29 Apr 2005 13:25:57 -0400
*Subject*: GCC 4.0, Fast Math, and Acovea

`Hello,`

`I've been down (due to illness) for a couple of months, so I don't know
if folk here are aware of something I discovered about GCC 4.0 on AMD64:
-ffast-math is "broken" on AMD64/x86_64.`

`Specifically, the -funsafe-math-optimizations flag doesn't work
correctly on AMD64 because the default on that platform is -mfpmath=sse.
Without specifying -mfpmath=387, -funsafe-math-optimizations does not
generate inline processor instructions for most floating-point functions.`

`Let's put it another way: Manually selecting -mfpmath=387 cuts run-times
by 50% for programs dependent on functions like sin() and sqrt(), as
compared to -funsafe-math-optimizations by itself.`

`I'm not so sure this is much a bug as it is an error in the way
-funsafe-math-optimizations is handled. My suggestion is the
-funsafe-math-optimizations set -mfpmath=387 on AMD64 -- otherwise, it
is completely useless, as is (of course) -ffast-math.`

`For those who are interested, I've updated Acovea (my optimization
analyzer) to version 5.0, and have published an analysis of GCC's 3.4
and 4.0 on Opteron, where I'm finding a *consistent* 6-20% improvement
in code speed over any -On option. You can find the main Acovea web page at:`

`http://www.coyotegulch.com/products/acovea/index.html`

`I'll be doing Pentium and other tests as time permits.`

`..Scott`