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

GCC 4.0, Fast Math, and Acovea


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:

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


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