[Bug middle-end/64225] -funsafe-math-optimizations generates call to pow where multiply instruction would do

jgreenhalgh at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Dec 8 15:30:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64225

--- Comment #5 from jgreenhalgh at gcc dot gnu.org ---
I've seen similar behavior on an HPC benchmark I was looking at.

The problem here is the interaction between fold-const.c, other passes, and
-fmath-errno.

Take this testcase:

void
foo (double x)
{
  x * x;
}

fold-const.c is going to see x *x and canonicalize it to a call to pow. No
other pass will want to touch it, because now it could set errno, so we get as
code generation:

foo:
    fmov    d1, 2.0e+0
    b    pow


If we add -fno-math-errno :

foo:
    ret

When I looked at this before I convinced myself that fold-const.c shouldn't be
doing the canonicalization to pow if we cared about errno - but I never spun a
patch for it - and I'm not sure I'm right.



More information about the Gcc-bugs mailing list