re PR tree-optimization/47228 (wrong code with loop)

2011-01-27  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.

From-SVN: r169331
This commit is contained in:
Martin Jambor 2011-01-27 14:41:51 +01:00 committed by Martin Jambor
parent 6c90babb57
commit e80b21edae
4 changed files with 44 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2011-01-27 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.
2011-01-27 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
* config/spu/spu-elf.h (ASM_SPEC): Remove.

View File

@ -1,3 +1,8 @@
2011-01-27 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/47228
* gcc.dg/torture/pr47228.c: New test.
2011-01-27 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* gcc.dg/tree-ssa/pr42585.c: Disable on s390 and s390x.

View File

@ -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;
}

View File

@ -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)))
{