[Bug tree-optimization/64541] FRE pass optimization failure

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 14 11:34:00 GMT 2015


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
                 CC|rguenther at suse dot de           |rguenth at gcc dot gnu.org
            Summary|.fre1 pass optimization     |FRE pass optimization
                   |failure                     |failure

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The sources are different in that 2.c dereferences *p one more time after
*q is stored to while 1.c dereferences *q for the return value.  Thus an
equivalent 2.c would be

int f (int ** p, int ** q)
{
        ++*p;
        *q = *p;
        return **q;
}

it is true that we can still optimize the original 2.c but only because
*p and *q are equivalent (but it is probably not worthwhile the compile-time
cost 
handling this). That is, we have to assume that p == q and thus the store to *q
invalidates the previously load *p.

I also think we have a duplicate report for this somewhere.

Simpler testcase (which is probably that in the duplicate):

int foo (int *p, int *q)
{
  *p = 1;
  *q = 1;
  return *p;
}



More information about the Gcc-bugs mailing list