For the following testcase:

__attribute__ ((noinline,noclone))
int
i_am_pure (int a)
{
  if (a>10)
    abort();
}

main()
{
  int a = i_am_pure (5) + i_am_pure (5);
  int b = i_am_pure (8) + i_am_pure (8);
  return a;
}

We get only one call to i_am_pure optimized out: 

main ()
{
  int a;
  int D.2721;

<bb 2>:
  D.2721_1 = i_am_pure (5);
  a_3 = D.2721_1 + D.2721_1;
  i_am_pure (8);
  i_am_pure (8);
  return a_3;

}

This is becasue removal is done as part of PRE and we are not removing
function calls without return value.  

Perhaps this can be improved to at least handle FRE quite easilly? In GCC we
now have about 1/4th of pure functions with WHOPR build and some results
especially in autogenerated files are unused and we end up with a lot of
redundant calls there.

Honza


-- 
           Summary: Redundant looping pure functions whose return value is
                    dead are not optimized out
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hubicka at gcc dot gnu dot org
  GCC host triplet: x86_64-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44462

Reply via email to