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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-10-27
          Component|c                           |tree-optimization
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  One thing is that the x + x -> 2*x canonicalization GCC has for
this
purpose is done in fold-const.c only (probably ok, see below).

Second thing is that the reassociation pass does _not_ do this optimization.
Testcase for that:

float foo (float x)
{
  float tem = x + x;
  float tem2 = tem + x;
  tem = tem2 + x;
  tem2 = tem + x;
  tem = tem2 + x;
  tem2 = tem + x;
  return tem2;
}

Sounds like a beginners project - look at undistribute_ops_list and enhance
it to handle the case of implicit * 1 (and maybe multi-use mults on the way).


Then of course when in a loop we don't have final value replacement for
non-integer types as we use SCEV for that.  The SCCP pass needs to be
amended here - I believe there is a duplicate bugreport for this somewhere.


Note that it can't do this w/o -funsafe-math-optimizations as "more accurate"
is only true if you see it mathematically vs. the FP operations.  But GCC
has to adhere to IEEE FP rules here.  It should be guarded with
-ffp-contract=fast rather than -fassociative-math though.

Reply via email to