[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#381970: gcc-4.1: [hppa][mips] gcc produces wrong code under -O2



Package: gcc-4.1
Version: 4.1.1-2
Severity: normal


When trying to solve #374396, we found that gcc with -O2 produces wrong
code in some corner cases in mips and hppa. The problem goes away with
-fno-delayed-brach, but -O0 -fdelayed-branch does not reproduce the
problem. I've tried unsuccessfully to recreate minimally the problem,
but it seems that there are factors governing the optimizations that
I'm not aware.

The problem is in this loop:

	while (cdouble < 0.0)
		cdouble += adouble;

Where cdouble and adouble are doubles (DUH!). It seems that with delayed
branchs, the addition is performed regardless of the result of the test
condition, and when the loop ends, the action is reversed by
substracting. As this is in floation point arithmetic, and the values
are big enough, there is a overflow which is not correctly reversed.

Please see the mentioned bug report for more details. Take into account
that this was causing a FTBFS in perl because it has a LOT of testcases,
but maybe other programs are affected.




Reply to: