O2 optimization differences

Joe Buck Joe.Buck@synopsys.COM
Wed Sep 29 18:04:00 GMT 2004


On Wed, Sep 29, 2004 at 03:10:12PM +0530, Sujith R. wrote:

> 	I am finding the output differences between O2 flagged , optimized
> version and a -g3 -gdwarf-2 flagged debugable version of a C++
> application , which does some very heavy , floating point , number
> crunching.  The differences are with very small numbers (close to 0)
> like 1.234E-11 being treated as 0, but some subsequent calculations go
> for a toss.

If you're running x86 hardware, you can see things like this.  The
floating point registers have extra precision (80 bits worth), but this
precision is lost when a register is spilled to memory.  Since this
differs depending on optimization level, you will see effects like this.

> 	The optimized and debug able binaries built on the same platform generate different outputs.  
> This we are observing on both the platforms mentioned below:
> 
> 	Platform A:  Linux 2.1 AS, gcc 2.96, RW SourcePro  3.0
> 	Platform B:  Linux 3.0 AS, gcc 3.2.3 , RW SourcePro 6.1

> However the debug able binaries generated on these two platforms give
> the same output.

Debug code is more likely to be consistent, since every assignment to
a named variable is forced to memory (losing the extra precision).



More information about the Gcc mailing list