Loop construction versus 0 frequency

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Sun Feb 4 20:39:00 GMT 2007


Hello,

> while looking into some dumps I noticed that loop construction code makes interesting
> decisions when frequencies are 0.  This patch fix the problem.
> The patch really just reindents and adds if (max_freq) guard for the
> whole profile driven code block.
> 
> Bootstrapped/regtested i686-linux, will commit it shortly.

sorry, please do not. I have just completely rewritten the code
(http://gcc.gnu.org/ml/gcc-patches/2007-02/msg00141.html); could you
check whether the problem appears also in the new version?

Zdenek

> Honza
> 
> 	* cfgloop.c (canonicalize_loop_headers): When frequencies are zero,
> 	do not attempt to use them.
> Index: cfgloop.c
> ===================================================================
> --- cfgloop.c	(revision 121572)
> +++ cfgloop.c	(working copy)
> @@ -402,30 +404,33 @@ canonicalize_loop_headers (void)
>  	if (LATCH_EDGE (e) &&
>  	    EDGE_FREQUENCY (e) > max_freq)
>  	  max_freq = EDGE_FREQUENCY (e);
> -      FOR_EACH_EDGE (e, ei, header->preds)
> -	if (LATCH_EDGE (e) &&
> -	    EDGE_FREQUENCY (e) >= max_freq / HEAVY_EDGE_RATIO)
> -	  {
> -	    if (heavy)
> +      if (max_freq)
> +	{
> +	  FOR_EACH_EDGE (e, ei, header->preds)
> +	    if (LATCH_EDGE (e) &&
> +		EDGE_FREQUENCY (e) >= max_freq / HEAVY_EDGE_RATIO)
>  	      {
> -		is_heavy = 0;
> -		break;
> +		if (heavy)
> +		  {
> +		    is_heavy = 0;
> +		    break;
> +		  }
> +		else
> +		  heavy = e;
>  	      }
> -	    else
> -	      heavy = e;
> -	  }
>  
> -      if (is_heavy)
> -	{
> -	  /* Split out the heavy edge, and create inner loop for it.  */
> -	  mfb_kj_edge = heavy;
> -	  tmp_edge = make_forwarder_block (header, mfb_keep_just,
> -					   update_latch_info);
> -	  alloc_aux_for_block (tmp_edge->dest, sizeof (int));
> -	  HEADER_BLOCK (tmp_edge->dest) = 1;
> -	  alloc_aux_for_edge (tmp_edge, sizeof (int));
> -	  LATCH_EDGE (tmp_edge) = 0;
> -	  HEADER_BLOCK (header)--;
> +	  if (is_heavy)
> +	    {
> +	      /* Split out the heavy edge, and create inner loop for it.  */
> +	      mfb_kj_edge = heavy;
> +	      tmp_edge = make_forwarder_block (header, mfb_keep_just,
> +					       update_latch_info);
> +	      alloc_aux_for_block (tmp_edge->dest, sizeof (int));
> +	      HEADER_BLOCK (tmp_edge->dest) = 1;
> +	      alloc_aux_for_edge (tmp_edge, sizeof (int));
> +	      LATCH_EDGE (tmp_edge) = 0;
> +	      HEADER_BLOCK (header)--;
> +	    }
>  	}
>  
>        if (HEADER_BLOCK (header) > 1)



More information about the Gcc-patches mailing list