diff mbox

[PR46649] sel-sched: don't try to delete the first BB in the region

Message ID alpine.LNX.2.00.1012141853520.5687@monoid.intra.ispras.ru
State New
Headers show

Commit Message

Alexander Monakov Dec. 14, 2010, 5:29 p.m. UTC
Hi,

Our BB removal machinery can not delete the first BB in the region.  This
patch restores the correct behaviour for purge_empty_blocks: we should skip
the first BB unconditionally, not only if it's a preheader.  It was
accidentally broken a while ago while fixing a different bug because I was not
aware of the limitation.

Bootstrapped & tested on x86_64-linux, OK for trunk?

2010-12-14  Alexander Monakov  <amonakov@ispras.ru>

	PR rtl-optimization/46649
	* sel-sched-ir.c (purge_empty_blocks): Unconditionally skip the first
	basic block in the region.

testsuite:
	g++.dg/opt/pr46649.C: New.

Comments

Vladimir Makarov Dec. 14, 2010, 5:35 p.m. UTC | #1
On 12/14/2010 12:29 PM, Alexander Monakov wrote:
> Hi,
>
> Our BB removal machinery can not delete the first BB in the region.  This
> patch restores the correct behaviour for purge_empty_blocks: we should skip
> the first BB unconditionally, not only if it's a preheader.  It was
> accidentally broken a while ago while fixing a different bug because I was not
> aware of the limitation.
>
> Bootstrapped&  tested on x86_64-linux, OK for trunk?
>
Ok, thanks.
> 2010-12-14  Alexander Monakov<amonakov@ispras.ru>
>
> 	PR rtl-optimization/46649
> 	* sel-sched-ir.c (purge_empty_blocks): Unconditionally skip the first
> 	basic block in the region.
>
> testsuite:
> 	g++.dg/opt/pr46649.C: New.
diff mbox

Patch

diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index 468dfd7..43619d9 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -3766,10 +3766,10 @@  tidy_control_flow (basic_block xbb, bool full_tidying)
 void
 purge_empty_blocks (void)
 {
-  /* Do not attempt to delete preheader.  */
-  int i = sel_is_loop_preheader_p (BASIC_BLOCK (BB_TO_BLOCK (0))) ? 1 : 0;
+  int i;
 
-  while (i < current_nr_blocks)
+  /* Do not attempt to delete the first basic block in the region.  */
+  for (i = 1; i < current_nr_blocks; )
     {
       basic_block b = BASIC_BLOCK (BB_TO_BLOCK (i));
 
diff --git a/gcc/testsuite/g++.dg/opt/pr46649.C b/gcc/testsuite/g++.dg/opt/pr46649.C
new file mode 100644
index 0000000..4dfaea4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr46649.C
@@ -0,0 +1,9 @@ 
+// { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } }
+// { dg-options "-fschedule-insns -fselective-scheduling" }
+
+void foo ()
+{
+  for (;;)
+    for (;;({break;}))
+    ;
+}