[patch] Always initialize current_loops in loop_optimizer_init

Zdenek Dvorak rakdver@kam.mff.cuni.cz
Fri May 25 19:30:00 GMT 2007


Hello,

when there are no loops in the function, loop_optimizer_init sets
current_loops to NULL (exactly as if loop_optimizer_init was not
called).  This behavior is somewhat inconsistent, and would force
special case handling on several places in the project to preserve
loop structures throughout compilation.

This patch makes us behave consistently in this case -- keep current_loops
initialized, but empty, recording no real loops (only the fake root of
the loop tree).  Instead of checking for current_loops != NULL, we now
check whether there are any loops (number_of_loops () > 1).  On several
places that used to check for current_loops != NULL, the check now can
be omited.

This also enables us to assert that loop_optimizer_init and
loop_optimizer_finalize calls are properly paired.

Bootstrapped & regtested on i686; I will wait for some time for comments
before commiting this change.

Zdenek

	* tree-vrp.c (execute_vrp): Do not check whether current_loops == NULL.
	* tree-chrec.c (evolution_function_is_invariant_rec_p): Ditto.
	* ifcvt.c (if_convert): Ditto.
	* tree-ssa-threadupdate.c (thread_block): Ditto.
	(thread_through_all_blocks): Ditto.  Assert that loops were analysed.
	* tree-ssa-loop-manip.c (rewrite_into_loop_closed_ssa,
	verify_loop_closed_ssa): Check number_of_loops instead of current_loops.
	* predict.c (tree_estimate_probability): Ditto.
	* tree-if-conv.c (main_tree_if_conversion): Ditto.
	* tree-ssa-loop-ch.c (copy_loop_headers): Ditto.
	* modulo-sched.c (sms_schedule): Ditto.
	* tree-scalar-evolution.c (scev_const_prop): Ditto.
	(scev_finalize): Do not do anything if scev analysis was not
	initialized.
	* cfgloopanal.c (mark_irreducible_loops): Do not check whether
	current_loops == NULL.
	(mark_loop_exit_edges): Check number_of_loops instead of current_loops.
	* loop-init.c (loop_optimizer_init): Do not free current_loops when
	there are no loops.
	(loop_optimizer_finalize): Assert that loops were analyzed.
	(rtl_move_loop_invariants, rtl_unswitch, rtl_unroll_and_peel_loops,
	rtl_doloop): Check number_of_loops instead of current_loops.
	* tree-ssa-loop.c (tree_loop_optimizer_init): Do not check whether
	current_loops == NULL.
	(tree_ssa_loop_init, tree_ssa_loop_im, tree_ssa_loop_unswitch,
	gate_tree_vectorize tree_linear_transform, check_data_deps,
	tree_ssa_loop_ivcanon, tree_ssa_empty_loop, tree_ssa_loop_bounds,
	tree_complete_unroll, tree_ssa_loop_prefetch, tree_ssa_loop_ivopts):
	Check number_of_loops instead of current_loops.
	(tree_ssa_loop_done): Do not check whether current_loops == NULL.
	* tree-ssa-pre.c (fini_pre): Do not take do_fre argument.  Always
	free loops if available.
	(execute_pre): Do not pass do_fre to fini_pre.

Index: tree-vrp.c
===================================================================
*** tree-vrp.c	(revision 124985)
--- tree-vrp.c	(working copy)
*************** static unsigned int
*** 5998,6008 ****
  execute_vrp (void)
  {
    loop_optimizer_init (LOOPS_NORMAL | LOOPS_HAVE_RECORDED_EXITS);
!   if (current_loops)
!     {
!       rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
!       scev_initialize ();
!     }
  
    insert_range_assertions ();
  
--- 5998,6005 ----
  execute_vrp (void)
  {
    loop_optimizer_init (LOOPS_NORMAL | LOOPS_HAVE_RECORDED_EXITS);
!   rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
!   scev_initialize ();
  
    insert_range_assertions ();
  
*************** execute_vrp (void)
*** 6023,6033 ****
    update_ssa (TODO_update_ssa);
  
    finalize_jump_threads ();
!   if (current_loops)
!     {
!       scev_finalize ();
!       loop_optimizer_finalize ();
!     }
  
    return 0;
  }
--- 6020,6027 ----
    update_ssa (TODO_update_ssa);
  
    finalize_jump_threads ();
!   scev_finalize ();
!   loop_optimizer_finalize ();
  
    return 0;
  }
Index: tree-ssa-threadupdate.c
===================================================================
*** tree-ssa-threadupdate.c	(revision 124985)
--- tree-ssa-threadupdate.c	(working copy)
*************** thread_block (basic_block bb, bool noloo
*** 530,536 ****
    /* If we thread the latch of the loop to its exit, the loop ceases to
       exist.  Make sure we do not restrict ourselves in order to preserve
       this loop.  */
!   if (current_loops && loop->header == bb)
      {
        e = loop_latch_edge (loop);
        e2 = e->aux;
--- 530,536 ----
    /* If we thread the latch of the loop to its exit, the loop ceases to
       exist.  Make sure we do not restrict ourselves in order to preserve
       this loop.  */
!   if (loop->header == bb)
      {
        e = loop_latch_edge (loop);
        e2 = e->aux;
*************** thread_block (basic_block bb, bool noloo
*** 552,558 ****
  	  /* If NOLOOP_ONLY is true, we only allow threading through the
  	     header of a loop to exit edges.  */
  	  || (noloop_only
- 	      && current_loops
  	      && bb == bb->loop_father->header
  	      && !loop_exit_edge_p (bb->loop_father, e2)))
  	{
--- 552,557 ----
*************** thread_through_all_blocks (bool may_peel
*** 1023,1028 ****
--- 1022,1030 ----
    struct loop *loop;
    loop_iterator li;
  
+   /* We must know about loops in order to preserve them.  */
+   gcc_assert (current_loops != NULL);
+ 
    if (threaded_edges == NULL)
      return false;
  
*************** thread_through_all_blocks (bool may_peel
*** 1031,1039 ****
  
    mark_threaded_blocks (threaded_blocks);
  
!   if (current_loops)
!     FOR_EACH_LOOP (li, loop, LI_FROM_INNERMOST)
        loop->copy = NULL;
  
    /* First perform the threading requests that do not affect
       loop structure.  */
--- 1033,1042 ----
  
    mark_threaded_blocks (threaded_blocks);
  
!   FOR_EACH_LOOP (li, loop, LI_FROM_INNERMOST)
!     {
        loop->copy = NULL;
+     }
  
    /* First perform the threading requests that do not affect
       loop structure.  */
*************** thread_through_all_blocks (bool may_peel
*** 1048,1063 ****
    /* Then perform the threading through loop headers.  We start with the
       innermost loop, so that the changes in cfg we perform won't affect
       further threading.  */
!   if (current_loops)
      {
!       FOR_EACH_LOOP (li, loop, LI_FROM_INNERMOST)
! 	{
! 	  if (!loop->header
! 	      || !bitmap_bit_p (threaded_blocks, loop->header->index))
! 	    continue;
  
! 	  retval |= thread_through_loop_header (loop, may_peel_loop_headers);
! 	}
      }
  
    if (retval)
--- 1051,1063 ----
    /* Then perform the threading through loop headers.  We start with the
       innermost loop, so that the changes in cfg we perform won't affect
       further threading.  */
!   FOR_EACH_LOOP (li, loop, LI_FROM_INNERMOST)
      {
!       if (!loop->header
! 	  || !bitmap_bit_p (threaded_blocks, loop->header->index))
! 	continue;
  
!       retval |= thread_through_loop_header (loop, may_peel_loop_headers);
      }
  
    if (retval)
Index: tree-ssa-loop-manip.c
===================================================================
*** tree-ssa-loop-manip.c	(revision 124985)
--- tree-ssa-loop-manip.c	(working copy)
*************** rewrite_into_loop_closed_ssa (bitmap cha
*** 360,366 ****
    unsigned i, old_num_ssa_names;
    bitmap names_to_rename;
  
!   if (!current_loops)
      return;
  
    loop_exits = get_loops_exits ();
--- 360,367 ----
    unsigned i, old_num_ssa_names;
    bitmap names_to_rename;
  
!   current_loops->state |= LOOP_CLOSED_SSA;
!   if (number_of_loops () <= 1)
      return;
  
    loop_exits = get_loops_exits ();
*************** rewrite_into_loop_closed_ssa (bitmap cha
*** 389,396 ****
    /* Fix up all the names found to be used outside their original
       loops.  */
    update_ssa (TODO_update_ssa);
- 
-   current_loops->state |= LOOP_CLOSED_SSA;
  }
  
  /* Check invariants of the loop closed ssa form for the USE in BB.  */
--- 390,395 ----
*************** verify_loop_closed_ssa (void)
*** 432,438 ****
    tree phi;
    unsigned i;
  
!   if (current_loops == NULL)
      return;
  
    verify_ssa (false);
--- 431,437 ----
    tree phi;
    unsigned i;
  
!   if (number_of_loops () <= 1)
      return;
  
    verify_ssa (false);
Index: tree-ssa-loop-ch.c
===================================================================
*** tree-ssa-loop-ch.c	(revision 124985)
--- tree-ssa-loop-ch.c	(working copy)
*************** copy_loop_headers (void)
*** 133,140 ****
  
    loop_optimizer_init (LOOPS_HAVE_PREHEADERS
  		       | LOOPS_HAVE_SIMPLE_LATCHES);
!   if (!current_loops)
!     return 0;
  
  #ifdef ENABLE_CHECKING
    verify_loop_structure ();
--- 133,143 ----
  
    loop_optimizer_init (LOOPS_HAVE_PREHEADERS
  		       | LOOPS_HAVE_SIMPLE_LATCHES);
!   if (number_of_loops () <= 1)
!     {
!       loop_optimizer_finalize ();
!       return 0;
!     }
  
  #ifdef ENABLE_CHECKING
    verify_loop_structure ();
Index: tree-scalar-evolution.c
===================================================================
*** tree-scalar-evolution.c	(revision 124985)
--- tree-scalar-evolution.c	(working copy)
*************** scev_analysis (void)
*** 2863,2868 ****
--- 2863,2870 ----
  void
  scev_finalize (void)
  {
+   if (!scalar_evolution_info)
+     return;
    htab_delete (scalar_evolution_info);
    BITMAP_FREE (already_instantiated);
    scalar_evolution_info = NULL;
*************** scev_const_prop (void)
*** 2885,2891 ****
    unsigned i;
    loop_iterator li;
  
!   if (!current_loops)
      return 0;
  
    FOR_EACH_BB (bb)
--- 2887,2893 ----
    unsigned i;
    loop_iterator li;
  
!   if (number_of_loops () <= 1)
      return 0;
  
    FOR_EACH_BB (bb)
Index: cfgloopanal.c
===================================================================
*** cfgloopanal.c	(revision 124985)
--- cfgloopanal.c	(working copy)
*************** mark_irreducible_loops (void)
*** 273,279 ****
    edge_iterator ei;
    int i, src, dest;
    struct graph *g;
!   int num = current_loops ? number_of_loops () : 1;
    int *queue1 = XNEWVEC (int, last_basic_block + num);
    int *queue2 = XNEWVEC (int, last_basic_block + num);
    int nq;
--- 273,279 ----
    edge_iterator ei;
    int i, src, dest;
    struct graph *g;
!   int num = number_of_loops ();
    int *queue1 = XNEWVEC (int, last_basic_block + num);
    int *queue2 = XNEWVEC (int, last_basic_block + num);
    int nq;
*************** mark_irreducible_loops (void)
*** 281,286 ****
--- 281,288 ----
    struct loop *cloop, *loop;
    loop_iterator li;
  
+   gcc_assert (current_loops != NULL);
+ 
    /* Reset the flags.  */
    FOR_BB_BETWEEN (act, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
      {
*************** mark_irreducible_loops (void)
*** 302,337 ****
  	src = BB_REPR (act);
  	dest = BB_REPR (e->dest);
  
! 	if (current_loops)
  	  {
! 	    /* Ignore latch edges.  */
! 	    if (e->dest->loop_father->header == e->dest
! 		&& e->dest->loop_father->latch == act)
! 	      continue;
! 
! 	    /* Edges inside a single loop should be left where they are.  Edges
! 	       to subloop headers should lead to representative of the subloop,
! 	       but from the same place.
! 
! 	       Edges exiting loops should lead from representative
! 	       of the son of nearest common ancestor of the loops in that
! 	       act lays.  */
! 
! 	    if (e->dest->loop_father->header == e->dest)
! 	      dest = LOOP_REPR (e->dest->loop_father);
! 
! 	    if (!flow_bb_inside_loop_p (act->loop_father, e->dest))
! 	      {
! 		depth = 1 + loop_depth (find_common_loop (act->loop_father,
! 						e->dest->loop_father));
! 		if (depth == loop_depth (act->loop_father))
! 		  cloop = act->loop_father;
! 		else
! 		  cloop = VEC_index (loop_p, act->loop_father->superloops,
! 				     depth);
  
! 		src = LOOP_REPR (cloop);
! 	      }
  	  }
  
  	add_edge (g, src, dest, e);
--- 304,335 ----
  	src = BB_REPR (act);
  	dest = BB_REPR (e->dest);
  
! 	/* Ignore latch edges.  */
! 	if (e->dest->loop_father->header == e->dest
! 	    && e->dest->loop_father->latch == act)
! 	  continue;
! 
! 	/* Edges inside a single loop should be left where they are.  Edges
! 	   to subloop headers should lead to representative of the subloop,
! 	   but from the same place.
! 
! 	   Edges exiting loops should lead from representative
! 	   of the son of nearest common ancestor of the loops in that
! 	   act lays.  */
! 
! 	if (e->dest->loop_father->header == e->dest)
! 	  dest = LOOP_REPR (e->dest->loop_father);
! 
! 	if (!flow_bb_inside_loop_p (act->loop_father, e->dest))
  	  {
! 	    depth = 1 + loop_depth (find_common_loop (act->loop_father,
! 						      e->dest->loop_father));
! 	    if (depth == loop_depth (act->loop_father))
! 	      cloop = act->loop_father;
! 	    else
! 	      cloop = VEC_index (loop_p, act->loop_father->superloops, depth);
  
! 	    src = LOOP_REPR (cloop);
  	  }
  
  	add_edge (g, src, dest, e);
*************** mark_irreducible_loops (void)
*** 347,358 ****
        queue1[nq++] = BB_REPR (act);
      }
  
!   if (current_loops)
      {
!       FOR_EACH_LOOP (li, loop, 0)
! 	{
! 	  queue1[nq++] = LOOP_REPR (loop);
! 	}
      }
    dfs (g, queue1, nq, queue2, false);
    for (i = 0; i < nq; i++)
--- 345,353 ----
        queue1[nq++] = BB_REPR (act);
      }
  
!   FOR_EACH_LOOP (li, loop, 0)
      {
!       queue1[nq++] = LOOP_REPR (loop);
      }
    dfs (g, queue1, nq, queue2, false);
    for (i = 0; i < nq; i++)
*************** mark_irreducible_loops (void)
*** 366,373 ****
    free (queue1);
    free (queue2);
  
!   if (current_loops)
!     current_loops->state |= LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS;
  }
  
  /* Counts number of insns inside LOOP.  */
--- 361,367 ----
    free (queue1);
    free (queue2);
  
!   current_loops->state |= LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS;
  }
  
  /* Counts number of insns inside LOOP.  */
*************** mark_loop_exit_edges (void)
*** 605,611 ****
    basic_block bb;
    edge e;
  
!   if (!current_loops)
      return;
  
    FOR_EACH_BB (bb)
--- 599,605 ----
    basic_block bb;
    edge e;
  
!   if (number_of_loops () <= 1)
      return;
  
    FOR_EACH_BB (bb)
Index: tree-chrec.c
===================================================================
*** tree-chrec.c	(revision 124985)
--- tree-chrec.c	(working copy)
*************** evolution_function_is_invariant_rec_p (t
*** 974,986 ****
  bool
  evolution_function_is_invariant_p (tree chrec, int loopnum)
  {
!   if (evolution_function_is_constant_p (chrec))
!     return true;
!   
!   if (current_loops != NULL)
!     return evolution_function_is_invariant_rec_p (chrec, loopnum);
! 
!   return false;
  }
  
  /* Determine whether the given tree is an affine multivariate
--- 974,980 ----
  bool
  evolution_function_is_invariant_p (tree chrec, int loopnum)
  {
!   return evolution_function_is_invariant_rec_p (chrec, loopnum);
  }
  
  /* Determine whether the given tree is an affine multivariate
Index: modulo-sched.c
===================================================================
*** modulo-sched.c	(revision 124985)
--- modulo-sched.c	(working copy)
*************** sms_schedule (void)
*** 893,900 ****
  
    loop_optimizer_init (LOOPS_HAVE_PREHEADERS
  		       | LOOPS_HAVE_RECORDED_EXITS);
!   if (!current_loops)
!     return;  /* There are no loops to schedule.  */
  
    /* Initialize issue_rate.  */
    if (targetm.sched.issue_rate)
--- 893,903 ----
  
    loop_optimizer_init (LOOPS_HAVE_PREHEADERS
  		       | LOOPS_HAVE_RECORDED_EXITS);
!   if (number_of_loops () <= 1)
!     {
!       loop_optimizer_finalize ();
!       return;  /* There are no loops to schedule.  */
!     }
  
    /* Initialize issue_rate.  */
    if (targetm.sched.issue_rate)
Index: loop-init.c
===================================================================
*** loop-init.c	(revision 124985)
--- loop-init.c	(working copy)
*************** loop_optimizer_init (unsigned flags)
*** 51,64 ****
    flow_loops_find (loops);
    current_loops = loops;
  
-   if (number_of_loops () <= 1)
-     {
-       /* No loops (the 1 returned by number_of_loops corresponds to the fake
- 	 loop that we put as a root of the loop tree).  */
-       loop_optimizer_finalize ();
-       return;
-     }
- 
    if (flags & LOOPS_MAY_HAVE_MULTIPLE_LATCHES)
      {
        /* If the loops may have multiple latches, we cannot canonicalize
--- 51,56 ----
*************** loop_optimizer_finalize (void)
*** 105,112 ****
    struct loop *loop;
    basic_block bb;
  
!   if (!current_loops)
!     return;
  
    FOR_EACH_LOOP (li, loop, 0)
      {
--- 97,103 ----
    struct loop *loop;
    basic_block bb;
  
!   gcc_assert (current_loops != NULL);
  
    FOR_EACH_LOOP (li, loop, 0)
      {
*************** gate_rtl_move_loop_invariants (void)
*** 244,250 ****
  static unsigned int
  rtl_move_loop_invariants (void)
  {
!   if (current_loops)
      move_loop_invariants ();
    return 0;
  }
--- 235,241 ----
  static unsigned int
  rtl_move_loop_invariants (void)
  {
!   if (number_of_loops () > 1)
      move_loop_invariants ();
    return 0;
  }
*************** gate_rtl_unswitch (void)
*** 277,283 ****
  static unsigned int
  rtl_unswitch (void)
  {
!   if (current_loops)
      unswitch_loops ();
    return 0;
  }
--- 268,274 ----
  static unsigned int
  rtl_unswitch (void)
  {
!   if (number_of_loops () > 1)
      unswitch_loops ();
    return 0;
  }
*************** gate_rtl_unroll_and_peel_loops (void)
*** 310,316 ****
  static unsigned int
  rtl_unroll_and_peel_loops (void)
  {
!   if (current_loops)
      {
        int flags = 0;
  
--- 301,307 ----
  static unsigned int
  rtl_unroll_and_peel_loops (void)
  {
!   if (number_of_loops () > 1)
      {
        int flags = 0;
  
*************** static unsigned int
*** 359,365 ****
  rtl_doloop (void)
  {
  #ifdef HAVE_doloop_end
!   if (current_loops)
      doloop_optimize_loops ();
  #endif
    return 0;
--- 350,356 ----
  rtl_doloop (void)
  {
  #ifdef HAVE_doloop_end
!   if (number_of_loops () > 1)
      doloop_optimize_loops ();
  #endif
    return 0;
Index: ifcvt.c
===================================================================
*** ifcvt.c	(revision 124985)
--- ifcvt.c	(working copy)
*************** if_convert (int x_life_data_ok)
*** 3953,3963 ****
    gcc_assert (! no_new_pseudos || reload_completed);
  
    loop_optimizer_init (AVOID_CFG_MODIFICATIONS);
!   if (current_loops)
!     {
!       mark_loop_exit_edges ();
!       loop_optimizer_finalize ();
!     }
    free_dominance_info (CDI_DOMINATORS);
  
    /* Compute postdominators if we think we'll use them.  */
--- 3953,3960 ----
    gcc_assert (! no_new_pseudos || reload_completed);
  
    loop_optimizer_init (AVOID_CFG_MODIFICATIONS);
!   mark_loop_exit_edges ();
!   loop_optimizer_finalize ();
    free_dominance_info (CDI_DOMINATORS);
  
    /* Compute postdominators if we think we'll use them.  */
Index: tree-ssa-loop.c
===================================================================
*** tree-ssa-loop.c	(revision 124985)
--- tree-ssa-loop.c	(working copy)
*************** tree_loop_optimizer_init (void)
*** 45,53 ****
  {
    loop_optimizer_init (LOOPS_NORMAL
  		       | LOOPS_HAVE_RECORDED_EXITS);
-   if (!current_loops)
-     return;
- 
    rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
  }
  
--- 45,50 ----
*************** static unsigned int
*** 82,88 ****
  tree_ssa_loop_init (void)
  {
    tree_loop_optimizer_init ();
!   if (!current_loops)
      return 0;
  
    scev_initialize ();
--- 79,85 ----
  tree_ssa_loop_init (void)
  {
    tree_loop_optimizer_init ();
!   if (number_of_loops () <= 1)
      return 0;
  
    scev_initialize ();
*************** struct tree_opt_pass pass_tree_loop_init
*** 111,117 ****
  static unsigned int
  tree_ssa_loop_im (void)
  {
!   if (!current_loops)
      return 0;
  
    tree_ssa_lim ();
--- 108,114 ----
  static unsigned int
  tree_ssa_loop_im (void)
  {
!   if (number_of_loops () <= 1)
      return 0;
  
    tree_ssa_lim ();
*************** struct tree_opt_pass pass_lim = 
*** 146,152 ****
  static unsigned int
  tree_ssa_loop_unswitch (void)
  {
!   if (!current_loops)
      return 0;
  
    return tree_ssa_unswitch_loops ();
--- 143,149 ----
  static unsigned int
  tree_ssa_loop_unswitch (void)
  {
!   if (number_of_loops () <= 1)
      return 0;
  
    return tree_ssa_unswitch_loops ();
*************** tree_vectorize (void)
*** 187,193 ****
  static bool
  gate_tree_vectorize (void)
  {
!   return flag_tree_vectorize && current_loops;
  }
  
  struct tree_opt_pass pass_vectorize =
--- 184,190 ----
  static bool
  gate_tree_vectorize (void)
  {
!   return flag_tree_vectorize && number_of_loops () > 1;
  }
  
  struct tree_opt_pass pass_vectorize =
*************** struct tree_opt_pass pass_vectorize =
*** 213,219 ****
  static unsigned int
  tree_linear_transform (void)
  {
!   if (!current_loops)
      return 0;
  
    linear_transform_loops ();
--- 210,216 ----
  static unsigned int
  tree_linear_transform (void)
  {
!   if (number_of_loops () <= 1)
      return 0;
  
    linear_transform_loops ();
*************** struct tree_opt_pass pass_linear_transfo
*** 249,255 ****
  static unsigned int
  check_data_deps (void)
  {
!   if (!current_loops)
      return 0;
  
    tree_check_data_deps ();
--- 246,252 ----
  static unsigned int
  check_data_deps (void)
  {
!   if (number_of_loops () <= 1)
      return 0;
  
    tree_check_data_deps ();
*************** struct tree_opt_pass pass_check_data_dep
*** 284,290 ****
  static unsigned int
  tree_ssa_loop_ivcanon (void)
  {
!   if (!current_loops)
      return 0;
  
    return canonicalize_induction_variables ();
--- 281,287 ----
  static unsigned int
  tree_ssa_loop_ivcanon (void)
  {
!   if (number_of_loops () <= 1)
      return 0;
  
    return canonicalize_induction_variables ();
*************** struct tree_opt_pass pass_scev_cprop =
*** 345,351 ****
  static unsigned int
  tree_ssa_empty_loop (void)
  {
!   if (!current_loops)
      return 0;
  
    return remove_empty_loops ();
--- 342,348 ----
  static unsigned int
  tree_ssa_empty_loop (void)
  {
!   if (number_of_loops () <= 1)
      return 0;
  
    return remove_empty_loops ();
*************** struct tree_opt_pass pass_empty_loop =
*** 374,380 ****
  static unsigned int
  tree_ssa_loop_bounds (void)
  {
!   if (!current_loops)
      return 0;
  
    estimate_numbers_of_iterations ();
--- 371,377 ----
  static unsigned int
  tree_ssa_loop_bounds (void)
  {
!   if (number_of_loops () <= 1)
      return 0;
  
    estimate_numbers_of_iterations ();
*************** struct tree_opt_pass pass_record_bounds 
*** 404,410 ****
  static unsigned int
  tree_complete_unroll (void)
  {
!   if (!current_loops)
      return 0;
  
    return tree_unroll_loops_completely (flag_unroll_loops
--- 401,407 ----
  static unsigned int
  tree_complete_unroll (void)
  {
!   if (number_of_loops () <= 1)
      return 0;
  
    return tree_unroll_loops_completely (flag_unroll_loops
*************** struct tree_opt_pass pass_complete_unrol
*** 441,447 ****
  static unsigned int
  tree_ssa_loop_prefetch (void)
  {
!   if (!current_loops)
      return 0;
  
    return tree_ssa_prefetch_arrays ();
--- 438,444 ----
  static unsigned int
  tree_ssa_loop_prefetch (void)
  {
!   if (number_of_loops () <= 1)
      return 0;
  
    return tree_ssa_prefetch_arrays ();
*************** struct tree_opt_pass pass_loop_prefetch 
*** 475,481 ****
  static unsigned int
  tree_ssa_loop_ivopts (void)
  {
!   if (!current_loops)
      return 0;
  
    tree_ssa_iv_optimize ();
--- 472,478 ----
  static unsigned int
  tree_ssa_loop_ivopts (void)
  {
!   if (number_of_loops () <= 1)
      return 0;
  
    tree_ssa_iv_optimize ();
*************** struct tree_opt_pass pass_iv_optimize =
*** 511,519 ****
  static unsigned int
  tree_ssa_loop_done (void)
  {
-   if (!current_loops)
-     return 0;
- 
    free_numbers_of_iterations_estimates ();
    scev_finalize ();
    loop_optimizer_finalize ();
--- 508,513 ----
Index: predict.c
===================================================================
*** predict.c	(revision 124985)
--- predict.c	(working copy)
*************** tree_estimate_probability (void)
*** 1353,1359 ****
    basic_block bb;
  
    loop_optimizer_init (0);
!   if (current_loops && dump_file && (dump_flags & TDF_DETAILS))
      flow_loops_dump (dump_file, NULL, 0);
  
    add_noreturn_fake_exit_edges ();
--- 1353,1359 ----
    basic_block bb;
  
    loop_optimizer_init (0);
!   if (dump_file && (dump_flags & TDF_DETAILS))
      flow_loops_dump (dump_file, NULL, 0);
  
    add_noreturn_fake_exit_edges ();
*************** tree_estimate_probability (void)
*** 1368,1374 ****
  
    mark_irreducible_loops ();
    record_loop_exits ();
!   if (current_loops)
      predict_loops ();
  
    FOR_EACH_BB (bb)
--- 1368,1374 ----
  
    mark_irreducible_loops ();
    record_loop_exits ();
!   if (number_of_loops () > 1)
      predict_loops ();
  
    FOR_EACH_BB (bb)
*************** estimate_loops (void)
*** 1731,1737 ****
    basic_block bb;
  
    /* Start by estimating the frequencies in the loops.  */
!   if (current_loops)
      estimate_loops_at_level (current_loops->tree_root->inner);
  
    /* Now propagate the frequencies through all the blocks.  */
--- 1731,1737 ----
    basic_block bb;
  
    /* Start by estimating the frequencies in the loops.  */
!   if (number_of_loops () > 1)
      estimate_loops_at_level (current_loops->tree_root->inner);
  
    /* Now propagate the frequencies through all the blocks.  */
Index: tree-if-conv.c
===================================================================
*** tree-if-conv.c	(revision 124985)
--- tree-if-conv.c	(working copy)
*************** main_tree_if_conversion (void)
*** 1105,1111 ****
    loop_iterator li;
    struct loop *loop;
  
!   if (!current_loops)
      return 0;
  
    FOR_EACH_LOOP (li, loop, 0)
--- 1105,1111 ----
    loop_iterator li;
    struct loop *loop;
  
!   if (number_of_loops () <= 1)
      return 0;
  
    FOR_EACH_LOOP (li, loop, 0)
Index: tree-ssa-pre.c
===================================================================
*** tree-ssa-pre.c	(revision 124985)
--- tree-ssa-pre.c	(working copy)
*************** init_pre (bool do_fre)
*** 3801,3807 ****
  /* Deallocate data structures used by PRE.  */
  
  static void
! fini_pre (bool do_fre)
  {
    basic_block bb;
    unsigned int i;
--- 3801,3807 ----
  /* Deallocate data structures used by PRE.  */
  
  static void
! fini_pre (void)
  {
    basic_block bb;
    unsigned int i;
*************** fini_pre (bool do_fre)
*** 3849,3855 ****
  	  && TREE_CODE (SSA_NAME_VALUE (name)) == VALUE_HANDLE)
  	SSA_NAME_VALUE (name) = NULL;
      }
!   if (!do_fre && current_loops)
      loop_optimizer_finalize ();
  }
  
--- 3849,3855 ----
  	  && TREE_CODE (SSA_NAME_VALUE (name)) == VALUE_HANDLE)
  	SSA_NAME_VALUE (name) = NULL;
      }
!   if (current_loops != NULL)
      loop_optimizer_finalize ();
  }
  
*************** execute_pre (bool do_fre)
*** 3915,3921 ****
        realify_fake_stores ();
      }
  
!   fini_pre (do_fre);
  }
  
  /* Gate and execute functions for PRE.  */
--- 3915,3921 ----
        realify_fake_stores ();
      }
  
!   fini_pre ();
  }
  
  /* Gate and execute functions for PRE.  */



More information about the Gcc-patches mailing list