http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49599
Summary: FRE/DSE not performing well on aggregates Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: jamb...@gcc.gnu.org In the following testcase: struct S { int i; unsigned short f1; char f2; unsigned short f3[2], f4; }; int foo (struct S *p) { struct S l; l = *p; l.i++; *p = l; } in which SRA does not do total scalarization because of the array in the aggregate (we do it only for structures), the optimized dump looks like this: foo (struct S * p) { int l$i; struct S l; int D.1967; <bb 2>: l = *p_1(D); l$i_6 = p_1(D)->i; D.1967_3 = l$i_6 + 1; *p_1(D) = l; p_1(D)->i = D.1967_3; return; } The loads and stores from and to l should be eliminated, probably by FRE and DSE.