This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix create_preheader ICE (PR rtl-optimization/84872)


Hi!

When create_preheader is called with CP_FALLTHRU_PREHEADERS and
the loop header is cold, but the bb dominating the loop is hot (or vice
versa) and there are just 2 incoming edges into the header, we use
split_edge, which unfortunately make the new bb use the partition of the
source rather than destination, so this newly created preheader is never
fallthru without jump, because the edge is EDGE_CROSSING.

Fixed by forcing to use make_forwarder_block in that case, that uses the
partition of the bb on which it is called (i.e. loop header).

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2018-04-06  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/84872
	* cfgloopmanip.c (create_preheader): Use make_forwarder_block even if
	nentry == 1 when CP_FALLTHRU_PREHEADERS and single_entry is
	EDGE_CROSSING edge.

	* gcc.dg/graphite/pr84872.c: New test.

--- gcc/cfgloopmanip.c.jj	2018-01-03 10:19:56.065534103 +0100
+++ gcc/cfgloopmanip.c	2018-04-06 12:57:53.141922946 +0200
@@ -1494,7 +1494,9 @@ create_preheader (struct loop *loop, int
 
   mfb_kj_edge = loop_latch_edge (loop);
   latch_edge_was_fallthru = (mfb_kj_edge->flags & EDGE_FALLTHRU) != 0;
-  if (nentry == 1)
+  if (nentry == 1
+      && ((flags & CP_FALLTHRU_PREHEADERS) == 0
+  	  || (single_entry->flags & EDGE_CROSSING) == 0))
     dummy = split_edge (single_entry);
   else
     {
--- gcc/testsuite/gcc.dg/graphite/pr84872.c.jj	2018-04-06 13:06:07.017014715 +0200
+++ gcc/testsuite/gcc.dg/graphite/pr84872.c	2018-04-06 13:05:46.358011993 +0200
@@ -0,0 +1,19 @@
+/* PR rtl-optimization/84872 */
+/* { dg-do compile { target pthread } } */
+/* { dg-options "-O1 -floop-parallelize-all -freorder-blocks-and-partition -fschedule-insns2 -fselective-scheduling2 -fsel-sched-pipelining -fno-tree-dce" } */
+
+void
+foo (int x)
+{
+  int a[2];
+  int b, c = 0;
+
+  for (b = 0; b < 2; ++b)
+    a[b] = 0;
+  for (b = 0; b < 2; ++b)
+    a[b] = 0;
+
+  while (c < 1)
+    while (x < 1)
+      ++x;
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]