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
{
char 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.
forwprop is looking for a MULT_EXPR which does not exist in this case.
--
Summary: Missed forw prop with indirect ref and addr. (and char
types or sizeof(type) == 1)
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
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=31982