re PR tree-optimization/70602 (wrong code at -O1 and above on x86_64-linux-gnu in...
authorJakub Jelinek <jakub@redhat.com>
Tue, 12 Apr 2016 09:08:43 +0000 (11:08 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 12 Apr 2016 09:08:43 +0000 (11:08 +0200)
PR tree-optimization/70602
* tree-sra.c (generate_subtree_copies): Don't write anything into
constant pool decls.

* gcc.c-torture/execute/pr70602.c: New test.

From-SVN: r234895

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr70602.c [new file with mode: 0644]
gcc/tree-sra.c

index edd33043879ab8d8c976f3d99decbef9d447970d..62c837239b699a4f4431b15c0cd9491682a35d3b 100644 (file)
@@ -1,5 +1,9 @@
 2016-04-12  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/70602
+       * tree-sra.c (generate_subtree_copies): Don't write anything into
+       constant pool decls.
+
        * omp-low.c (lower_omp_target): Use GOMP_MAP_FIRSTPRIVATE_INT
        regardless whether there are depend clauses or not.
 
index aa5c77c6bc66d7a8753ead2fb26d03dc4418ab7b..7aaee6ed008669d4c1459f2ca92a848c1dca5cb7 100644 (file)
@@ -1,3 +1,8 @@
+2016-04-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/70602
+       * gcc.c-torture/execute/pr70602.c: New test.
+
 2016-04-11  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        PR target/70381
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr70602.c b/gcc/testsuite/gcc.c-torture/execute/pr70602.c
new file mode 100644 (file)
index 0000000..c6628b0
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR tree-optimization/70602 */
+
+struct __attribute__((packed)) S
+{
+  int s : 1;
+  int t : 20;
+};
+
+int a, b, c;
+
+int
+main ()
+{
+  for (; a < 1; a++)
+    {
+      struct S e[] = { {0, 9}, {0, 9}, {0, 9}, {0, 0}, {0, 9}, {0, 9}, {0, 9}, 
+                      {0, 0}, {0, 9}, {0, 9}, {0, 9}, {0, 0}, {0, 9}, {0, 9}, 
+                      {0, 9}, {0, 0}, {0, 9}, {0, 9}, {0, 9}, {0, 0}, {0, 9} };
+      b = b || e[0].s;
+      c = e[0].t;
+    }
+  return 0;
+}
index 738c1a77bda5894e92e37259eb04b28f2f8bfa37..1d2b1c5ad050f7013e83c3220274c8bbe42ba077 100644 (file)
@@ -2743,6 +2743,9 @@ generate_subtree_copies (struct access *access, tree agg,
                         gimple_stmt_iterator *gsi, bool write,
                         bool insert_after, location_t loc)
 {
+  /* Never write anything into constant pool decls.  See PR70602.  */
+  if (!write && constant_decl_p (agg))
+    return;
   do
     {
       if (chunk_size && access->offset >= start_offset + chunk_size)