diff mbox

Fix PR52803

Message ID Pine.LNX.4.64.1204021139010.1852@jbgna.fhfr.qr
State New
Headers show

Commit Message

Richard Biener April 2, 2012, 9:42 a.m. UTC
This fixes PR52803 - when we do not enter the pass_loop2 sub-pass
queue nothing will execute pass_rtl_loop_done.  But we still need
to destroy loops, which are preserved until after pass_loop2.
Doing so in the gate of pass_loop2 is ugly, but destroyed
properties are ignored if the gate returns false.  Another
solution would be to destroy loops earlier dependent on
gate_handle_loop2 - but that's equally ugly.  Another solution
would be to add a pass after pass_loop2 that only destroys
loops (also ugly).

Honza, how is this part of the pass manager supposed to work?

Thanks,
Richard.

2012-04-02  Richard Guenther  <rguenther@suse.de>

	PR middle-end/52803
	* loop-init.c (gate_handle_loop2): Destroy loops here if
	we don't enter RTL loop optimizers.

	* gcc.dg/pr52803.c: New testcase.

Comments

Jan Hubicka April 2, 2012, 1:29 p.m. UTC | #1
> 
> This fixes PR52803 - when we do not enter the pass_loop2 sub-pass
> queue nothing will execute pass_rtl_loop_done.  But we still need
> to destroy loops, which are preserved until after pass_loop2.
> Doing so in the gate of pass_loop2 is ugly, but destroyed
> properties are ignored if the gate returns false.  Another
> solution would be to destroy loops earlier dependent on
> gate_handle_loop2 - but that's equally ugly.  Another solution
> would be to add a pass after pass_loop2 that only destroys
> loops (also ugly).
> 
> Honza, how is this part of the pass manager supposed to work?

Did not think of much of alternatives. We can have pass just after loop
destroying the loop structure or perhaps we can simply run loop init/uninit
always even if all the subpasses are disabled.  Would be a bit smoother, but
also wasteful.

Honza
diff mbox

Patch

Index: gcc/loop-init.c
===================================================================
--- gcc/loop-init.c	(revision 186066)
+++ gcc/loop-init.c	(working copy)
@@ -158,15 +158,24 @@  loop_optimizer_finalize (void)
 static bool
 gate_handle_loop2 (void)
 {
-  return (optimize > 0
-  	  && (flag_move_loop_invariants
-              || flag_unswitch_loops
-              || flag_peel_loops
-              || flag_unroll_loops
+  if (optimize > 0
+      && (flag_move_loop_invariants
+	  || flag_unswitch_loops
+	  || flag_peel_loops
+	  || flag_unroll_loops
 #ifdef HAVE_doloop_end
-	      || (flag_branch_on_count_reg && HAVE_doloop_end)
+	  || (flag_branch_on_count_reg && HAVE_doloop_end)
 #endif
-	      ));
+	 ))
+    return true;
+  else
+    {
+      /* No longer preserve loops, remove them now.  */
+      cfun->curr_properties &= ~PROP_loops;
+      if (current_loops)
+	loop_optimizer_finalize ();
+      return false;
+    } 
 }
 
 struct rtl_opt_pass pass_loop2 =
Index: gcc/testsuite/gcc.dg/pr52803.c
===================================================================
--- gcc/testsuite/gcc.dg/pr52803.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr52803.c	(revision 0)
@@ -0,0 +1,4 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O -fno-move-loop-invariants" } */
+
+int main () { return 0; }