[Bug tree-optimization/68105] optimizing repeated floating point addition to multiplication
glisse at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu May 5 13:59:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68105
--- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to zboson from comment #0)
> In addition, the following equations are always true even without
> associative math.
>
> 2*a = a + a
> 3*a = a + a + a
> 4*a = a + a + a + a
> 5*a = a + a + a + a + a
>
> It turns out that GCC does simplify a + a + a + a to 4*a but only with
> associative math enabled e.g. with -Ofast when it could do it with -O3.
This "always true" needs some qualification. It is wrong with -frounding-math,
where you have to stop at 3 IIRC.
(In reply to kugan from comment #2)
> Looks like a duplicate of PR63586.
I am not convinced this is completely a dup. The patch
https://gcc.gnu.org/ml/gcc-patches/2016-05/msg00368.html would probably close
PR63586, but not this one since all of the testcases about float in that patch
use -ffast-math.
More information about the Gcc-bugs
mailing list