This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Fldcw, rounding and optimizations
Sebastien Loisel wrote:
> What I fear though is that it may be very difficult to write efficient
> interval arithmetic code with gcc. The portable code (using fenv.h) is
> bound to be slow, with one call per rounding mode change
> (bits/fenvinline.h really ought to have asm volatile inlines -- but even
> if it did, the generated code would suck.) The nonportable approach I'm
> using above seems to do a bit better (I'll be exercising it later to make
> sure) but I think it's still less good than what one might want.
A problem is that for the most efficient code, you want GCC to group
together FP operations that are using the same rounding mode. You
don't really want to prevent it from reording the arithmetic
operations, you just want it to give the right answers :)
To do this right, C99's _Pragma approach seems like the right thing,
to tell GCC what fldcw value is required before every FP operation
that it generates. Then it can reorder the FP operations as best it
can, and insert fldcw instructions only where needed.
-- Jamie