This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Fldcw, rounding and optimizations
On 14-Aug-2003, Loisel, Sebastien <loisel@amazon.com> wrote:
> I know about fenv.h, I'm trying to save some cycles.
...
> Also, should this be considered a bug in g++ (the FPU optimizer changes
> the semantics of my program, hence the optimizer is wrong) or a bug in
> my code (I'm inserting inline assembler behind g++'s back, which g++
> can't be expected to grok anyway?)
The latter. If you need to change rounding modes, and <fenv.h> is
available, you should use it. If the compiler doesn't do a good job
of optimizing the resulting code, then send a bug report with the
"pessimizes-code" keyword.
> Are the g++ FPU optimizations always correct in the absence of rounding
> mode tweakage?
Define "correct"?
> (Do all programs output the exact same floating point
> numbers at all precision levels, if floating point rounding mode is
> left alone?)
No. For example, on some architectures (e.g. x86) you can get different
precision depending on whether an intermediate expression gets stored
on the C stack or in floating point registers. See the documentation
for the `-ffloat-store' option for more information on that.
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.