public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH PR94125]Update post order number for merged SCC
@ 2020-03-15  6:12 bin.cheng
  2020-03-15  9:49 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: bin.cheng @ 2020-03-15  6:12 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 927 bytes --]

Hi,
This simple patch fixes PR94125 by updating post order number for merged SCC.
The root cause is after computing SCC with runtime alias edges skipped, the post
order info is changed and it's possible a partition is scheduled after another where
should be scheduled before.  Note that updating to the minimal post order number
is safe, only partitions separated from SCC because of skipping runtime alias edges
can be assigned larger post oder than the original precedent one.

Bootstrap and test on x86_64, test case also added.

Thanks,
bin

2020-03-15  Bin Cheng  <bin.cheng@linux.alibaba.com>

        PR tree-optimization/94125
        * tree-loop-distribution.c
        (loop_distribution::break_alias_scc_partitions): Update post ordeer
        number for merged scc.

gcc/testsuite
2020-03-15  Bin Cheng  <bin.cheng@linux.alibaba.com>

        PR tree-optimization/94125
        * gcc.dg/tree-ssa/pr94125.c: New test.

[-- Attachment #2: 0001-pr94125.patch --]
[-- Type: application/octet-stream, Size: 2317 bytes --]

Subject: [PATCH] pr94125

---
 gcc/testsuite/gcc.dg/tree-ssa/pr94125.c | 41 +++++++++++++++++++++++++++++++++
 gcc/tree-loop-distribution.c            | 13 ++++-------
 2 files changed, 46 insertions(+), 8 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr94125.c

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 0000000..c339e51
--- /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 35d3821..f85f6df 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);
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH PR94125]Update post order number for merged SCC
  2020-03-15  6:12 [PATCH PR94125]Update post order number for merged SCC bin.cheng
@ 2020-03-15  9:49 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2020-03-15  9:49 UTC (permalink / raw)
  To: bin.cheng, bin.cheng via Gcc-patches, GCC Patches

On March 15, 2020 7:12:26 AM GMT+01:00, "bin.cheng via Gcc-patches" <gcc-patches@gcc.gnu.org> wrote:
>Hi,
>This simple patch fixes PR94125 by updating post order number for
>merged SCC.
>The root cause is after computing SCC with runtime alias edges skipped,
>the post
>order info is changed and it's possible a partition is scheduled after
>another where
>should be scheduled before.  Note that updating to the minimal post
>order number
>is safe, only partitions separated from SCC because of skipping runtime
>alias edges
>can be assigned larger post oder than the original precedent one.
>
>Bootstrap and test on x86_64, test case also added.

OK. 

Thanks, 
Richard. 

>Thanks,
>bin
>
>2020-03-15  Bin Cheng  <bin.cheng@linux.alibaba.com>
>
>        PR tree-optimization/94125
>        * tree-loop-distribution.c
>    (loop_distribution::break_alias_scc_partitions): Update post ordeer
>        number for merged scc.
>
>gcc/testsuite
>2020-03-15  Bin Cheng  <bin.cheng@linux.alibaba.com>
>
>        PR tree-optimization/94125
>        * gcc.dg/tree-ssa/pr94125.c: New test.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-15  9:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-15  6:12 [PATCH PR94125]Update post order number for merged SCC bin.cheng
2020-03-15  9:49 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).