https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85957

--- Comment #14 from Rich Felker <bugdal at aerifal dot cx> ---
> No problems: FLT_EVAL_METHOD==2 means "evaluate all operations and constants 
> to the range and precision of the long double type", which is what really 
> occurs. The consequence is indeed double rounding when storing in memory, but 
> this can happen at *any* time even without -ffloat-store (due to spilling), 
> because you are never sure that registers are still available; see some 
> reports in bug 323.

It sounds like you misunderstand the standard's requirements on, and GCC's
implementation of, FLT_EVAL_METHOD==2/excess-precision. The availability of
registers does not in any way affect the result, because when expressions are
evaluated with excess precision, any spills must take place in the format of
float_t or double_t (long double) and are thereby transparent to the
application. The buggy behavior prior to -fexcess-precision=standard (and now
produced with -fexcess-precision=fast which is default in "gnu" modes) spills
in the nominal type, producing nondeterministic results that depend on the
compiler's transformations and that lead to situations like this bug (where the
optimizer has been lied to that two expressions are equal, but they're not).

> Double rounding can be a problem with some codes, but this just means that 
> the code is not compatible with FLT_EVAL_METHOD==2. For some floating-point 
> algorithms, double rounding is not a problem at all, while keeping a result 
> in extended precision will make them fail.

With standards-conforming behavior, the rounding of an operation and of storage
to an object of float/double type are discrete roundings and you can observe
and handle the intermediate value between them. With -ffloat-store, every
operation inherently has a double-rounding attached to it. This behavior is
non-conforming but at least deterministic, and is what I was referring to in my
previous comment. But I think this is largely a distraction from the issue at
hand; I was only pointing out that -ffloat-store is a workaround, but one with
its own (often severe) problems.

Reply via email to