This is the mail archive of the
mailing list for the GCC project.
Re: Floating point trouble with x86's extended precision
- From: "Joseph S. Myers" <jsm at polyomino dot org dot uk>
- To: Jim Wilson <wilson at tuliptree dot org>
- Cc: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>, lucier at math dot purdue dot edu, gcc at gcc dot gnu dot org
- Date: Wed, 20 Aug 2003 23:04:25 +0100 (BST)
- Subject: Re: Floating point trouble with x86's extended precision
- References: <200308201627.h7KGRHaX017733@relay.rwth-aachen.de><3F43E07B.email@example.com>
On Wed, 20 Aug 2003, Jim Wilson wrote:
> instructions, and this causes unexpected rounding problems. The easiest
> way to see this is to write an expression that needs more than 8
> register to evaluate. Reload will spill registers in the middle of the
> expression, and they will be truncated to 64-bits when spilled because
> the optimizer thinks we have 64-bit values. This results in rounding
> error. The same expression can give different results at different
> optimization levels because different pseudos get spilled. This is
> clearly a gcc bug. This problem has been known for over a decade, and
What is clearly a bug here is the definition of FLT_EVAL_METHOD for i387
floating point - which should be -1, not 2, as long as we don't have
80-bit spills (as has been noted before, e.g.
> 4) Try using -ffloat-store. This works for some but not all programs.
> -ffloat-store forces user declared variables to be allocated on the
> stack, and hence avoid the in register excess precision problems.
The first bug in this context would be that it needs to be documented that
-ffloat-store (as well as -std=whatever -pedantic) is needed to get a
conforming implementation: casts and assignments are required (C99
subclause 184.108.40.206) to remove excess precision.
The second bug would be that this may not always work for casts (we
discard casts to the same type very early, but when there is excess
precision they do have a required effect of removing that excess
Joseph S. Myers