[gcc(refs/users/marxin/heads/marxin-gcc-benchmark-branch)] Update post order number for merged SCC.
Martin Liska
marxin@gcc.gnu.org
Mon Mar 30 10:50:11 GMT 2020
https://gcc.gnu.org/g:e4e9a59105a81cdd6c1328b0a5ed9fe4cc82840e
commit e4e9a59105a81cdd6c1328b0a5ed9fe4cc82840e
Author: Bin Cheng <bin.cheng@linux.alibaba.com>
Date: Mon Mar 16 11:09:14 2020 +0800
Update post order number for merged SCC.
Function loop_distribution::break_alias_scc_partitions needs to compute
SCC with runtime alias edges skipped. As a result, partitions could be
re-assigned larger post order number than SCC's precedent partition and
distributed before the precedent one. This fixes the issue by updating
the merged partition to the minimal post order in SCC.
gcc/
PR tree-optimization/94125
* tree-loop-distribution.c
(loop_distribution::break_alias_scc_partitions): Update post order
number for merged scc.
gcc/testsuite/
PR tree-optimization/94125
* gcc.dg/tree-ssa/pr94125.c: New test.
Diff:
---
gcc/ChangeLog | 7 ++++++
gcc/testsuite/ChangeLog | 5 ++++
gcc/testsuite/gcc.dg/tree-ssa/pr94125.c | 41 +++++++++++++++++++++++++++++++++
gcc/tree-loop-distribution.c | 13 ++++-------
4 files changed, 58 insertions(+), 8 deletions(-)
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6718f712b8b..53c9622afa2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2020-03-16 Bin Cheng <bin.cheng@linux.alibaba.com>
+
+ PR tree-optimization/94125
+ * tree-loop-distribution.c
+ (loop_distribution::break_alias_scc_partitions): Update post order
+ number for merged scc.
+
2020-03-15 H.J. Lu <hongjiu.lu@intel.com>
PR target/89229
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f79f1c7c303..ab0406656d2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-03-16 Bin Cheng <bin.cheng@linux.alibaba.com>
+
+ PR tree-optimization/94125
+ * gcc.dg/tree-ssa/pr94125.c: New test.
+
2020-03-15 H.J. Lu <hongjiu.lu@intel.com>
PR target/89229
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr94125.c b/gcc/testsuite/gcc.dg/tree-ssa/pr94125.c
new file mode 100644
index 00000000000..c339e51f482
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr94125.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-options "-O3" } */
+
+unsigned char b, f;
+short d[1][8][1], *g = &d[0][3][0];
+
+void __attribute__((noinline)) foo ()
+{
+ int k[256] = { 0, 0, 0, 4, 0, 0 };
+ for (int c = 252; c >= 0; c--)
+ {
+ b = f;
+ *g = k[c + 3];
+ k[c + 1] = 0;
+ }
+ for (int i = 0; i < 8; i++)
+ if (d[0][i][0] != 0)
+ __builtin_abort ();
+}
+
+void __attribute__((noinline)) bar ()
+{
+ int k[256] = { 0, 0, 0, 4, 0, 0 };
+ k[255] = 4;
+ for (int c = 0; c <=252; c++)
+ {
+ b = f;
+ *g = k[c + 3];
+ k[c + 1] = 0;
+ }
+ for (int i = 0; i < 8; i++)
+ if ((i == 3 && d[0][i][0] != 4) || (i != 3 && d[0][i][0] != 0))
+ __builtin_abort ();
+}
+
+int main ()
+{
+ foo ();
+ bar ();
+ return 0;
+}
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 35d3821bb07..44423215332 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -2489,14 +2489,11 @@ loop_distribution::break_alias_scc_partitions (struct graph *rdg,
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;
- }
+ /* Update to the minimal postordeer number of vertices in scc so
+ that merged partition is sorted correctly against others. */
+ if (pg->vertices[j].post > pg->vertices[k].post)
+ pg->vertices[j].post = pg->vertices[k].post;
+
partition_merge_into (NULL, first, partition, FUSE_SAME_SCC);
(*partitions)[k] = NULL;
partition_free (partition);
More information about the Gcc-cvs
mailing list