Enqueue all SRA links for write flag propagation
authorMartin Jambor <mjambor@suse.cz>
Wed, 6 Sep 2017 09:25:00 +0000 (11:25 +0200)
committerMartin Jambor <jamborm@gcc.gnu.org>
Wed, 6 Sep 2017 09:25:00 +0000 (11:25 +0200)
2017-09-06  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/82078
gcc/
* tree-sra.c (sort_and_splice_var_accesses): Move call to
add_access_to_work_queue...
(build_accesses_from_assign): ...here.
(propagate_all_subaccesses): Make sure racc is the group
representative, if there is one.

gcc/testsuite/
* gcc.dg/tree-ssa/pr82078.c: New test.

From-SVN: r251756

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

index e35d6b35b225d9dfb13041aab6ee7c62495fbef7..50c61063083e61aff4fb604e75bc61053478f872 100644 (file)
@@ -1,3 +1,12 @@
+2017-09-06  Martin Jambor  <mjambor@suse.cz>
+
+       PR tree-optimization/82078
+       * tree-sra.c (sort_and_splice_var_accesses): Move call to
+       add_access_to_work_queue...
+       (build_accesses_from_assign): ...here.
+       (propagate_all_subaccesses): Make sure racc is the group
+       representative, if there is one.
+
 2017-09-06  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/82095
index 2b168296cd7e856d1d21cef17c4b8379754260fe..75f6f89f567d20de52a008293f069ff095dd8247 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-06  Martin Jambor  <mjambor@suse.cz>
+
+       PR tree-optimization/82078
+       * gcc.dg/tree-ssa/pr82078.c: New test.
+
 2017-09-06  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/82095
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr82078.c b/gcc/testsuite/gcc.dg/tree-ssa/pr82078.c
new file mode 100644 (file)
index 0000000..3774986
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+/* { dg-options "-O" } */
+
+struct S0 {
+  signed f4;
+  signed f9 : 5;
+} a[6][5], b = {2}
+
+;
+int c, d;
+int fn1() {
+  struct S0 e[5][6];
+  struct S0 f;
+  b = f = e[2][5] = a[5][0];
+  if (d)
+    ;
+  else
+    return f.f9;
+  e[c][45] = a[4][4];
+}
+
+int main() {
+  fn1();
+  if (b.f4 != 0)
+    __builtin_abort ();
+  return 0;
+}
index 68edbce21b327589ddc8098a5f956f7f74ca77f1..163b7a2d03b27a6527c735019b9812e58419b982 100644 (file)
@@ -1359,6 +1359,8 @@ build_accesses_from_assign (gimple *stmt)
       link->lacc = lacc;
       link->racc = racc;
       add_link_to_rhs (racc, link);
+      add_access_to_work_queue (racc);
+
       /* Let's delay marking the areas as written until propagation of accesses
         across link, unless the nature of rhs tells us that its data comes
         from elsewhere.  */
@@ -2118,7 +2120,6 @@ sort_and_splice_var_accesses (tree var)
       access->grp_total_scalarization = total_scalarization;
       access->grp_partial_lhs = grp_partial_lhs;
       access->grp_unscalarizable_region = unscalarizable_region;
-      add_access_to_work_queue (access);
 
       *prev_acc_ptr = access;
       prev_acc_ptr = &access->next_grp;
@@ -2712,6 +2713,8 @@ propagate_all_subaccesses (void)
       struct access *racc = pop_access_from_work_queue ();
       struct assign_link *link;
 
+      if (racc->group_representative)
+       racc= racc->group_representative;
       gcc_assert (racc->first_link);
 
       for (link = racc->first_link; link; link = link->next)