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 PR52803


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.

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; }


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