This testcase should pass:
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-forwprop" }  */

/* We should be able to optimize this to b.t[i] = 1 during
   early optimizations.  */

struct a
{
  int t[10];
};

struct a b;

void f(__SIZE_TYPE__ i)
{
  int *c = b.t;
  c[i] = 1;
}

/* { dg-final { scan-tree-dump "t\\\[i.*\\\] = 1;" "forwprop1" { xfail *-*-* }
} } */
/* { dg-final { scan-tree-dump "t\\\[i.*\\\] = 1;" "forwprop2" } } */
/* { dg-final { cleanup-tree-dump "forwprop?" } } */

---------

I found this while fixing up forwprop for the pointer plus branch.


-- 
           Summary: Missed forw prop with indirect ref and addr.
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org


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

Reply via email to