This is the mail archive of the gcc-help@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: linux i-86 problem with rounding (gcc-3.1.1 & 3.2)


On Wed, Sep 18, 2002 at 02:58:54PM -0500, Buddy Lott wrote:
> While I agree, that processor type would affect the precision of the
> answer, I would think the compiler should consistent when
> optimizing/not optimizing code. I would think it should never change
> the result of the code.

The observed behavior is a result of a peculiarity of the x86
processor: floating-point numbers have higher precision in registers
than in memory. Therefore, the result depends on what calculations
are done in registers, which is affected by optimization.

Gcc has an option -ffloat-store, which causes floating-point numbers
always to be stored in memory. With this option, the program gives
the same result with every optimization level.

Martin


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