This is the mail archive of the gcc@gcc.gnu.org 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]

Re: -ffast-math and floating point reordering


In

http://gcc.gnu.org/ml/gcc/2004-03/msg01492.html

Geert Bosch writes

This is a good point, and it also serves as an illustration
of weaknesses in the "just add another command-line option" philosophy.
For example, in writing various elementary floating-point functions, it
definitely is necessary to prevent unsafe transformations in order to
attain accuracy requirements for the entire domain of the function.


On the other hand, it is also desirable in many cases to inline these functions, especially when one of the operands is a constant. How can we specify that this code that relies on strict semantics will not be affected by the command-line options.


A similar issue exists the other way around. There may be library functions where the various transformations are known to be safe, and which may benefit from them. Think of a graphics routines for coordinate transformations for example.


One solution seems to allow having tree-level operations for addition, multiplications etc. that specify wether they are - associative - communicative - potentially trapping - supporting non-finite value semantics - supporting non-default rounding


This way front ends can set these attributes depending on language rules and/or constructs in the source specifying certain behavior.

Another, perhaps equivalent approach, would be to have lexically scoped "compilation environments" for code trees. These compilation environments would be set up at the point where the tree is defined; if a function is inlined, it would be inlined with its lexically-defined compilation environment intact. The tree is then transformed using the rules of the associated compilation environment.


This is done now in the Gambit-C Scheme compiler. If a function is declared to be compiled without runtime error checking, then this property is carried wherever this function is inlined. This may be clearer when compiler options are declared using inline pragmas rather than with compiler switches attached to entire files.

Brad


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