]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix PR/70013
authorAlan Lawrence <alan.lawrence@arm.com>
Fri, 11 Mar 2016 12:08:01 +0000 (12:08 +0000)
committerAlan Lawrence <alalaw01@gcc.gnu.org>
Fri, 11 Mar 2016 12:08:01 +0000 (12:08 +0000)
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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/sra-20.c [new file with mode: 0644]
gcc/tree-sra.c

index 09ea7f7bd7a277d890702c4aa4ad8459f1767f4f..2014d7f4c37b804f09b05ba361c9e17959f1855d 100644 (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
index a1035ef7a46dcc4ea67c97299f5453c8017229f2..a945aa2ed5e88c52b65ee516c07a74cc0e0be4da 100644 (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
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/sra-20.c b/gcc/testsuite/gcc.dg/tree-ssa/sra-20.c
new file mode 100644 (file)
index 0000000..5002c24
--- /dev/null
@@ -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;
+}
index 06c39c3de76cb6a8ed0470626b8d8c2615366665..a3fb59ce5a4c3f58560dd749bc69d57c286e53bf 100644 (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;
 }