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]

Re: What is acceptable for -ffast-math? (Was: associative law in combine)


<<In 99% of all cases, the information of the subtleties of floating point
arithmetic simply was never there in the program gcc tries to compile.
Why? Becuase the programmer didn't even _intend_ any of the subtleties, or
even knew about them.

Gcc trying to enforce them doesn't add any value.
>>

The 99% is a highly excessive estimate here. Many many people understand
and expect that the compiler will NOT mess around with their floating-point
expressions. It has always been the case in Fortran that you can depend
on parentheses being respected, and programmers do indeed count on this.

Especially on an IEEE machine, fpt is not just some vague approximation
of real numbers, it is a well defined arithmetic system with well defined
rules, and in the world of numerical programming, people are not as
incompetent as you claim. Sure, a casual C programmer using an occasional
bit of fpt arithmetic may well not know what they are doing, but a compiler
should aim its implementation of fpt at those writing numeric codes. Giving
wrong answers fast is definitely not useful.

Part of the trouble here is that many compiler writers and systems people
simply don't know floating-point semantics well enough, and have often made
improper assumptions about optimizations etc, which have caused a lot of trouble
in the past. 

I cannot believe that any expert in floating-point would agree that it is just
fine to do the kind of optimizations you suggest by default, and indeed I have
trouble seeing that this kind of "optimization" is ever anything but a bug!


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