aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorBin Cheng <bin.cheng@linux.alibaba.com>2020-07-09 18:10:03 +0800
committerBin Cheng <bin.cheng@linux.alibaba.com>2020-07-09 18:14:26 +0800
commitdd21b03900085c4d60bf03207ad28bcbfbc86a4b (patch)
tree9faa1ceaf5595589ac8c7966a9a8fbff60c6a37f /gcc
parent5acef69f9d3d9f3c537b5e5157519edf02f86c4d (diff)
downloadgcc-dd21b03900085c4d60bf03207ad28bcbfbc86a4b.zip
gcc-dd21b03900085c4d60bf03207ad28bcbfbc86a4b.tar.gz
gcc-dd21b03900085c4d60bf03207ad28bcbfbc86a4b.tar.bz2
Schedule reduction partition in the last.
If reduction partition's SCC is broken by runtime alias checks, force a negative post order to it so that it will be scheduled in the last. 2020-07-09 Bin Cheng <bin.cheng@linux.alibaba.com> gcc/ PR tree-optimization/95804 * tree-loop-distribution.c (break_alias_scc_partitions): Force negative post order to reduction partition. gcc/testsuite/ PR tree-optimization/95804 * gcc.dg/tree-ssa/pr95804.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr95804.c18
-rw-r--r--gcc/tree-loop-distribution.c21
2 files changed, 36 insertions, 3 deletions
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr95804.c b/gcc/testsuite/gcc.dg/tree-ssa/pr95804.c
new file mode 100644
index 0000000..83c0ab4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr95804.c
@@ -0,0 +1,18 @@
+/* PR tree-optimization/95804 */
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+int a, b, c, d, e, f;
+void g() {
+ short *h = (short*)&d;
+ char *i = (char*)&b;
+ for (; e; e++) {
+ for (; f; f++) {
+ b = 3;
+ if ((c = 8) >= *i)
+ a = 5 ? *h : 0;
+ h = (short*)g;
+ }
+ i = (char*)&c;
+ }
+}
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 9bc94e5..888af48 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -2509,10 +2509,25 @@ loop_distribution::break_alias_scc_partitions (struct graph *rdg,
}
}
/* Restore the postorder information if it's corrupted in finding SCC
- with alias dependence edges skipped. */
+ with alias dependence edges skipped. If reduction partition's SCC is
+ broken by runtime alias checks, we force a negative post order to it
+ making sure it will be scheduled in the last. */
if (num_sccs_no_alias > 0)
- for (i = 0; i < pg->n_vertices; ++i)
- pg->vertices[i].post = cbdata.vertices_post[i];
+ {
+ j = -1;
+ for (i = 0; i < pg->n_vertices; ++i)
+ {
+ pg->vertices[i].post = cbdata.vertices_post[i];
+ struct pg_vdata *data = (struct pg_vdata *)pg->vertices[i].data;
+ if (data->partition && partition_reduction_p (data->partition))
+ {
+ gcc_assert (j == -1);
+ j = i;
+ }
+ }
+ if (j >= 0)
+ pg->vertices[j].post = -1;
+ }
free (cbdata.vertices_component);
free (cbdata.vertices_post);