Message ID | 20110127124653.GA8864@virgil.arch.suse.de |
---|---|
State | New |
Headers | show |
On Thu, 27 Jan 2011, Martin Jambor wrote: > Hi, > > at two points I kept a call to build_ref_for_offset in tree-sra.c > instead of converting them to build_ref_for_model like all the others. > There was a reason for this but I cannot recall what exactly it was, > except that it would have been useless before Eric's change to > build_ref_for_model. Nevertheless, after that change > build_ref_for_model can help us avoid PR 47228. So this patch > converts these two calls too. > > I have bootstrapped and tested this on x86_64-linux and I have also > ran testsuite of c and c++ on i686 without any issues. OK for trunk? Ok. Thanks, Richard. > Thanks, > > Martin > > > > 2011-01-26 Martin Jambor <mjambor@suse.cz> > > PR tree-optimization/47228 > * tree-sra.c (sra_modify_assign): Use build_ref_for_model instead of > build_ref_for_offset. > > * testsuite/gcc.dg/torture/pr47228.c: New test. > > > Index: src/gcc/testsuite/gcc.dg/torture/pr47228.c > =================================================================== > --- /dev/null > +++ src/gcc/testsuite/gcc.dg/torture/pr47228.c > @@ -0,0 +1,31 @@ > +/* { dg-do run } */ > + > +struct S4 > +{ > + unsigned f0:24; > +} __attribute__((__packed__)); > + > +struct S4 g_10 = { > + 6210831 > +}; > + > +struct S4 func_2 (int x) > +{ > + struct S4 l_8[2] = { > + {0}, {0} > + }; > + g_10 = l_8[1]; > + for (; x<2; x++) { > + struct S4 tmp = { > + 11936567 > + }; > + l_8[x] = tmp; > + } > + return g_10; > +} > + > +int main (void) > +{ > + func_2 (0); > + return 0; > +} > Index: src/gcc/tree-sra.c > =================================================================== > --- src.orig/gcc/tree-sra.c > +++ src/gcc/tree-sra.c > @@ -2739,15 +2739,13 @@ sra_modify_assign (gimple *stmt, gimple_ > && !contains_bitfld_comp_ref_p (lhs) > && !access_has_children_p (lacc)) > { > - lhs = build_ref_for_offset (loc, lhs, 0, TREE_TYPE (rhs), > - gsi, false); > + lhs = build_ref_for_model (loc, lhs, 0, racc, gsi, false); > gimple_assign_set_lhs (*stmt, lhs); > } > else if (AGGREGATE_TYPE_P (TREE_TYPE (rhs)) > && !contains_vce_or_bfcref_p (rhs) > && !access_has_children_p (racc)) > - rhs = build_ref_for_offset (loc, rhs, 0, TREE_TYPE (lhs), > - gsi, false); > + rhs = build_ref_for_model (loc, rhs, 0, lacc, gsi, false); > > if (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs))) > { > >
Index: src/gcc/testsuite/gcc.dg/torture/pr47228.c =================================================================== --- /dev/null +++ src/gcc/testsuite/gcc.dg/torture/pr47228.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +struct S4 +{ + unsigned f0:24; +} __attribute__((__packed__)); + +struct S4 g_10 = { + 6210831 +}; + +struct S4 func_2 (int x) +{ + struct S4 l_8[2] = { + {0}, {0} + }; + g_10 = l_8[1]; + for (; x<2; x++) { + struct S4 tmp = { + 11936567 + }; + l_8[x] = tmp; + } + return g_10; +} + +int main (void) +{ + func_2 (0); + return 0; +} Index: src/gcc/tree-sra.c =================================================================== --- src.orig/gcc/tree-sra.c +++ src/gcc/tree-sra.c @@ -2739,15 +2739,13 @@ sra_modify_assign (gimple *stmt, gimple_ && !contains_bitfld_comp_ref_p (lhs) && !access_has_children_p (lacc)) { - lhs = build_ref_for_offset (loc, lhs, 0, TREE_TYPE (rhs), - gsi, false); + lhs = build_ref_for_model (loc, lhs, 0, racc, gsi, false); gimple_assign_set_lhs (*stmt, lhs); } else if (AGGREGATE_TYPE_P (TREE_TYPE (rhs)) && !contains_vce_or_bfcref_p (rhs) && !access_has_children_p (racc)) - rhs = build_ref_for_offset (loc, rhs, 0, TREE_TYPE (lhs), - gsi, false); + rhs = build_ref_for_model (loc, rhs, 0, lacc, gsi, false); if (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs))) {