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]

Re: Reorganize -ffast-math code.

Linux Torvalds wrote:

> You're an evil man.

Thank you.

> Yup, that pretty much means that every single intermediate result would
> have to go through memory to get truly predictable results.

The following computational model will give predictable results and will allow
simulation of IEEE floating point without extended precision as implemented
on other processors (except for things like PowePC fused multiply-add

0.  The programmer can declare the precision of all operations.

1.  All temporaries generated for a single expression are always maintained
in extended precision, even when spilled to the stack, and

2.  Each assignment to a variable is stored to memory. (And, if the value of
that variable is used later by dereferencing its lvalue, the value is loaded
from memory and the temporary that was stored to memory is not re-used.)

Item 0 is already implemented in the Linux-Gnu/glibc/gcc/x86 combination.  We
just need the possibility of setting items 1 and 2 through options; they don't
need to be the default.  The performance hit would be much less than with your
suggestion, and people designing algorithms can write them to exploit the x86
extended format precision and range within each expression to write simpler,
faster, and more accurate codes for some problems.  (And, if someone really
wants to simulate on x86 how IEEE floating point is done on Alpha, say, they
can use macros that explicitly incorporate the methods I gave in my previous post.)


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