This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/42286] October 23rd change to tree-ssa-pre.c breaks calculix on powerpc with -ffast-math
- From: "segher at kernel dot crashing dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Jan 2010 15:57:19 -0000
- Subject: [Bug tree-optimization/42286] October 23rd change to tree-ssa-pre.c breaks calculix on powerpc with -ffast-math
- References: <bug-42286-15150@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #7 from segher at kernel dot crashing dot org 2010-01-05 15:57 -------
With -fno-signed-zeroes, a-b*c is transformed to -(b*c-a), which is a machine
instruction. If the result would have been +0 before, it now is -0.
The code then takes the sqrt() of that; sqrt(-0) is -0. This then is
passed to atan2(), which has a discontinuity at 0, and we get wildly
diverging results.
The compiler does nothing wrong here; the transformation is perfectly
valid.
A solution might be to transform e.g. atan2(x,y) into atan2(+0.+x,+0.+y)
when -fno-signed-zeroes is in effect (and of course somehow make sure
those additions aren't optimised away). Similar for other math library
functions with discontinuities at +/- 0.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42286