While constant initializer reads are folded CCP doesn't propagate the following
in one invocation but requires a second CCP pass to clean up.

/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-ccp1" } */

static const int x;
int foo()
{
  int *p = &x;
  int y = *p;
  return y + 1;
}

/* { dg-final { scan-tree-dump "return 1;" "ccp1" } } */
/* { dg-final { cleanup-tree-dump "ccp1" } } */


-- 
           Summary: CCP does not propagate through constant initializers
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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

Reply via email to