Patchwork Fix PR 48374

login
register
mail settings
Submitter Andrey Belevantsev
Date Sept. 19, 2011, 8:49 a.m.
Message ID <4E77020F.90208@ispras.ru>
Download mbox | patch
Permalink /patch/115304/
State New
Headers show

Comments

Andrey Belevantsev - Sept. 19, 2011, 8:49 a.m.
Hello,

The problem here is the case where the selective scheduler doesn't expect 
having a block with zero successors.  The patch is near obvious which is 
why it was forgotten for nearly half a year, but still it applies cleanly 
and fixes the testcase, full testing is in progress.  OK for trunk and 
active branches if it succeeds?

Yours,
Andrey

2011-09-19  Andrey Belevantsev  <abel@ispras.ru>

	gcc/
	PR rtl-optimization/48374

	* sel-sched-ir.h (get_all_loop_exits): Stop iterating when the current 
block has zero successors.

	gcc/testsuite

	PR rtl-optimization/48374
	* gcc.dg/pr48374.c: New test.

+}

Patch

diff --git a/gcc/sel-sched-ir.h b/gcc/sel-sched-ir.h
index 5516da9..13af1b5 100644
--- a/gcc/sel-sched-ir.h
+++ b/gcc/sel-sched-ir.h
@@ -1119,7 +1119,8 @@  get_all_loop_exits (basic_block bb)
    /* If bb is empty, and we're skipping to loop exits, then
       consider bb as a possible gate to the inner loop now.  */
    while (sel_bb_empty_or_nop_p (bb)
-        && in_current_region_p (bb))
+        && in_current_region_p (bb)
+        && EDGE_COUNT (bb->succs) > 0)
      {
        bb = single_succ (bb);

diff --git a/gcc/testsuite/gcc.dg/pr48374.c b/gcc/testsuite/gcc.dg/pr48374.c
new file mode 100644
index 0000000..5486cec
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr48374.c
@@ -0,0 +1,16 @@ 
+/* { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } } */
+/* { dg-options "-O -fschedule-insns2 -fsel-sched-pipelining 
-fsel-sched-pipelining-outer-loops -fselective-scheduling2 --param 
max-sched-extend-regions-iters=2"  } */
+
+void foo (int y)
+{
+  switch (y)
+    {
+    case 3:
+    case 5:
+    case 7:
+    case 11:
+      break;
+    default:
+      __builtin_unreachable ();
+    }