From: jamborm Date: Thu, 27 Jan 2011 13:41:51 +0000 (+0000) Subject: 2011-01-27 Martin Jambor X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1fd38f81781c0cf96c671fc0861639107208bce3;p=thirdparty%2Fgcc.git 2011-01-27 Martin Jambor 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@169331 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0362a0a9202e..3bee8dd54f63 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-01-27 Martin Jambor + + PR tree-optimization/47228 + * tree-sra.c (sra_modify_assign): Use build_ref_for_model instead of + build_ref_for_offset. + 2011-01-27 Ulrich Weigand * config/spu/spu-elf.h (ASM_SPEC): Remove. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d1b76518d833..acaa86287d91 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-01-27 Martin Jambor + + PR tree-optimization/47228 + * gcc.dg/torture/pr47228.c: New test. + 2011-01-27 Andreas Krebbel * gcc.dg/tree-ssa/pr42585.c: Disable on s390 and s390x. diff --git a/gcc/testsuite/gcc.dg/torture/pr47228.c b/gcc/testsuite/gcc.dg/torture/pr47228.c new file mode 100644 index 000000000000..5bc9f0ad5113 --- /dev/null +++ b/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; +} diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 47613f6298a6..82d760121967 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -2739,15 +2739,13 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi) && !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))) {