re PR tree-optimization/82472 (ICE in generate_code_for_partition, at tree-loop-distr...
authorBin Cheng <bin.cheng@arm.com>
Wed, 11 Oct 2017 13:04:05 +0000 (13:04 +0000)
committerBin Cheng <amker@gcc.gnu.org>
Wed, 11 Oct 2017 13:04:05 +0000 (13:04 +0000)
PR tree-optimization/82472
* tree-loop-distribution.c (sort_partitions_by_post_order): Refine
comment.
(break_alias_scc_partitions): Update postorder number.

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

From-SVN: r253641

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr82472.c [new file with mode: 0644]
gcc/tree-loop-distribution.c

index 7dba1098f6a1b110f11d78aa57cbf3e79630f7cc..0028fc9a38af23c69cc84ef211de315c03d17c81 100644 (file)
@@ -1,3 +1,10 @@
+2017-10-11  Bin Cheng  <bin.cheng@arm.com>
+
+       PR tree-optimization/82472
+       * tree-loop-distribution.c (sort_partitions_by_post_order): Refine
+       comment.
+       (break_alias_scc_partitions): Update postorder number.
+
 2017-10-11  Martin Liska  <mliska@suse.cz>
 
        PR sanitizer/82490
index 04adb938767100b5c49086bace0227379ece0dab..23fccba5a677604848f48e973c0725d01c8c1739 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-11  Bin Cheng  <bin.cheng@arm.com>
+
+       PR tree-optimization/82472
+       * gcc.dg/tree-ssa/pr82472.c: New test.
+
 2017-10-11  Martin Liska  <mliska@suse.cz>
 
        PR sanitizer/82490
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr82472.c b/gcc/testsuite/gcc.dg/tree-ssa/pr82472.c
new file mode 100644 (file)
index 0000000..445c95f
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-loop-distribution" } */
+
+long int xj;
+
+int
+cx (long int *ox, short int mk, char tf)
+{
+  int si, f9;
+  char *p4 = &tf;
+  short int *rm = (tf != 0) ? (short int *)&f9 : &mk;
+
+  for (f9 = 0; f9 < 2; ++f9)
+    {
+      *rm = 0;
+      *p4 = *ox;
+      si = mk;
+      xj = 0;
+      while (p4 < (char *)rm)
+        ++p4;
+    }
+
+  return si;
+}
index 999b32ef06cd856b8db4f9385920b230bec7f7b1..98ad50e5e7ad4c510f1a197c0085732277b17867 100644 (file)
@@ -1943,7 +1943,8 @@ build_partition_graph (struct graph *rdg,
   return pg;
 }
 
-/* Sort partitions in PG by post order and store them in PARTITIONS.  */
+/* Sort partitions in PG in descending post order and store them in
+   PARTITIONS.  */
 
 static void
 sort_partitions_by_post_order (struct graph *pg,
@@ -1952,7 +1953,7 @@ sort_partitions_by_post_order (struct graph *pg,
   int i;
   struct pg_vdata *data;
 
-  /* Now order the remaining nodes in postorder.  */
+  /* Now order the remaining nodes in descending postorder.  */
   qsort (pg->vertices, pg->n_vertices, sizeof (vertex), pgcmp);
   partitions->truncate (0);
   for (i = 0; i < pg->n_vertices; ++i)
@@ -2048,7 +2049,7 @@ break_alias_scc_partitions (struct graph *rdg,
                            vec<struct partition *> *partitions,
                            vec<ddr_p> *alias_ddrs)
 {
-  int i, j, num_sccs, num_sccs_no_alias;
+  int i, j, k, num_sccs, num_sccs_no_alias;
   /* Build partition dependence graph.  */
   graph *pg = build_partition_graph (rdg, partitions, false);
 
@@ -2121,18 +2122,26 @@ break_alias_scc_partitions (struct graph *rdg,
          for (j = 0; partitions->iterate (j, &first); ++j)
            if (cbdata.vertices_component[j] == i)
              break;
-         for (++j; partitions->iterate (j, &partition); ++j)
+         for (k = j + 1; partitions->iterate (k, &partition); ++k)
            {
              struct pg_vdata *data;
 
-             if (cbdata.vertices_component[j] != i)
+             if (cbdata.vertices_component[k] != i)
                continue;
 
+             /* Update postorder number so that merged reduction partition is
+                sorted after other partitions.  */
+             if (!partition_reduction_p (first)
+                 && partition_reduction_p (partition))
+               {
+                 gcc_assert (pg->vertices[k].post < pg->vertices[j].post);
+                 pg->vertices[j].post = pg->vertices[k].post;
+               }
              partition_merge_into (NULL, first, partition, FUSE_SAME_SCC);
-             (*partitions)[j] = NULL;
+             (*partitions)[k] = NULL;
              partition_free (partition);
-             data = (struct pg_vdata *)pg->vertices[j].data;
-             gcc_assert (data->id == j);
+             data = (struct pg_vdata *)pg->vertices[k].data;
+             gcc_assert (data->id == k);
              data->partition = NULL;
            }
        }