Fix PR/70013

gcc:

	PR tree-optimization/70013
	* tree-sra.c (analyze_access_subtree): Also set grp_unscalarized_data
	for constant-pool entries.

gcc/testsuite:

	* gcc.dg/tree-ssa/sra-20.c: New.

From-SVN: r234138
This commit is contained in:
Alan Lawrence 2016-03-11 12:08:01 +00:00 committed by Alan Lawrence
parent 686d390a8f
commit 5c6706f77e
4 changed files with 32 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2016-03-11 Alan Lawrence <alan.lawrence@arm.com>
PR tree-optimization/70013
* tree-sra.c (analyze_access_subtree): Also set grp_unscalarized_data
for constant-pool entries.
2016-03-11 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/70174

View File

@ -1,3 +1,7 @@
2016-03-11 Alan Lawrence <alan.lawrence@arm.com>
* gcc.dg/tree-ssa/sra-20.c: New.
2016-03-11 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/70174

View File

@ -0,0 +1,20 @@
/* { dg-do compile } */
/* { dg-options "-O1 -Wall" } */
/* PR/70013, SRA of constant-pool loads removes initialization of part of d. */
#pragma pack (1)
struct S0 {
unsigned f0 : 17;
};
int c;
int
main (int argc, char **argv)
{
struct S0 d[] = { { 1 }, { 2 } };
struct S0 e = d[1];
c = d[0].f0;
__builtin_printf ("%x\n", e.f0);
return 0;
}

View File

@ -2427,7 +2427,8 @@ analyze_access_subtree (struct access *root, struct access *parent,
if (!hole || root->grp_total_scalarization)
root->grp_covered = 1;
else if (root->grp_write || TREE_CODE (root->base) == PARM_DECL)
else if (root->grp_write || TREE_CODE (root->base) == PARM_DECL
|| constant_decl_p (root->base))
root->grp_unscalarized_data = 1; /* not covered and written to */
return sth_created;
}