Bug 45570 - [4.6 Regression] ICE: in cfg_preds_1, at sel-sched-ir.c:4584
Summary: [4.6 Regression] ICE: in cfg_preds_1, at sel-sched-ir.c:4584
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.6.0
: P1 normal
Target Milestone: 4.6.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-06 23:53 UTC by Zdenek Sojka
Modified: 2011-04-07 06:50 UTC (History)
2 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-09-28 13:23:13


Attachments
reduced testcase (200 bytes, text/plain)
2010-09-06 23:54 UTC, Zdenek Sojka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2010-09-06 23:53:20 UTC
Command line:
$ gcc -O1 -fgcse -finline-small-functions -freorder-blocks -fschedule-insns2 -ftree-vrp -finline-functions -fselective-scheduling2 -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops -ftracer testcase.c
or
$ gcc -O2 -finline-functions -fselective-scheduling2 -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops -ftracer testcase.c
or
$ gcc -O3 -fselective-scheduling2 -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops -ftracer testcase.c

Compiler output:
$ gcc -O1 -fgcse -finline-small-functions -freorder-blocks -fschedule-insns2 -ftree-vrp -finline-functions -fselective-scheduling2 -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops -ftracer testcase.c
testcase.c: In function 'parser_get_next_parameter':
testcase.c:26:1: internal compiler error: in cfg_preds_1, at sel-sched-ir.c:4584
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Tested revisions:
r163921 - crash
r161659 - crash
r161170 - OK
Comment 1 Zdenek Sojka 2010-09-06 23:54:52 UTC
Created attachment 21721 [details]
reduced testcase
Comment 2 Andrey Belevantsev 2010-09-22 15:57:12 UTC
Neither of these option combinations fail for me on x86-64 with a recent trunk (164506).  We will investigate further with the given trunk revisions.
Comment 3 Andrey Belevantsev 2010-09-28 13:23:13 UTC
Confirmed.  It is hidden now by 163998.
The problem is simple, yet again when inserting a bookkeeping code together with pipelining outer loops, we can see the situation when we need to devise a positive seqno for a bookkeeping insn, yet we can't do that by examining its neighbours.  Fixed by relaxing the failing assert so that the first patch for PR40101 would provide an arbitrary positive value.

diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index 853205d..8a88c55 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -4580,8 +4580,12 @@ cfg_preds_1 (basic_block bb, insn_t **preds, int *n, int *size)
       basic_block pred_bb = e->src;
       insn_t bb_end = BB_END (pred_bb);
 
-      /* ??? This code is not supposed to walk out of a region.  */
-      gcc_assert (in_current_region_p (pred_bb));
+      if (!in_current_region_p (pred_bb))
+	{
+	  gcc_assert (flag_sel_sched_pipelining_outer_loops
+		      && current_loop_nest);
+	  continue;
+	}
 
       if (sel_bb_empty_p (pred_bb))
 	cfg_preds_1 (pred_bb, preds, n, size);
@@ -4594,7 +4598,9 @@ cfg_preds_1 (basic_block bb, insn_t **preds, int *n, int *size)
 	}
     }
 
-  gcc_assert (*n != 0);
+  gcc_assert (*n != 0
+	      || (flag_sel_sched_pipelining_outer_loops
+		  && current_loop_nest));
 }
 
 /* Find all predecessors of BB and record them in PREDS and their number
Comment 4 Andrey Belevantsev 2010-10-14 07:56:50 UTC
Author: abel
Date: Thu Oct 14 07:56:47 2010
New Revision: 165454

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=165454
Log:
	PR rtl-optimization/45570
	* sel-sched-ir.c (cfg_preds_1): When walking out of the region, assert
	that we are pipelining outer loops.  Allow returning zero predecessors.
	* gcc.dg/pr45570.c: New test. 

Added:
    trunk/gcc/testsuite/gcc.dg/pr45570.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/sel-sched-ir.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Andrey Belevantsev 2010-10-14 14:42:12 UTC
Fixed.
Comment 6 Andrey Belevantsev 2011-04-07 06:50:12 UTC
Author: abel
Date: Thu Apr  7 06:50:08 2011
New Revision: 172077

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172077
Log:
        Backport from mainline
        2010-10-14  Andrey Belevantsev  <abel@ispras.ru>

        PR rtl-optimization/45570
        * sel-sched-ir.c (cfg_preds_1): When walking out of the region,
        assert that we are pipelining outer loops.  Allow returning
        zero predecessors.


Added:
    branches/gcc-4_5-branch/gcc/testsuite/gcc.dg/pr45570.c
Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/sel-sched-ir.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog