From b4ec1d31a5d605c8bea45ca919d3a60dfdac771f Mon Sep 17 00:00:00 2001 From: Bin Cheng Date: Wed, 11 Oct 2017 13:04:05 +0000 Subject: [PATCH] re PR tree-optimization/82472 (ICE in generate_code_for_partition, at tree-loop-distribution.c:1145) 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 | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/tree-ssa/pr82472.c | 24 ++++++++++++++++++++++++ gcc/tree-loop-distribution.c | 25 +++++++++++++++++-------- 4 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr82472.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7dba1098f6a..0028fc9a38a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-10-11 Bin Cheng + + 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 PR sanitizer/82490 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 04adb938767..23fccba5a67 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-11 Bin Cheng + + PR tree-optimization/82472 + * gcc.dg/tree-ssa/pr82472.c: New test. + 2017-10-11 Martin Liska 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 index 00000000000..445c95fbc47 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr82472.c @@ -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; +} diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index 999b32ef06c..98ad50e5e7a 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -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 *partitions, vec *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; } } -- 2.30.2