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]

Re: code growth


On Fri, Aug 24, 2001 at 03:31:35PM +0200, Jan Hubicka wrote:
> Other way I see is to move the loop directly into i386.c, so I will
> compute it in epilogue expander, but IMO it makes somewhat strong
> assumption that the CFG is correct and frequencies up to date at
> time epilogue is emitted.  This should hold now, so I leave it at
> your choice what looks as better alternative.

I think most reasonable is leave the function in predict.c, 
but call it from the i386 prologue expander.  Pass in "limit"
as a parameter.

> +   /* Maximally BB_FREQ_MAX^2 so overflow won't happen.  */
> +   limit = ENTRY_BLOCK_PTR->frequency * BB_FREQ_MAX;
> +   for (i = 0; i < n_basic_blocks; i++)
> +     {
> +       basic_block bb = BASIC_BLOCK (i);
> +       rtx insn;
> +       for (insn = bb->head; insn != NEXT_INSN (bb->end) && sum < limit;
> + 	   insn = NEXT_INSN (insn))
> + 	{
> + 	  if (active_insn_p (insn))
> + 	    {
> + 	      sum += bb->frequency;
> + 	    }
> + 	}
> +     }
> +   if (sum >= limit)

You are not safe from overflow.  To be safe from overflow, you
have to return out of the middle of the inner loop.  I.e.

	sum += bb->frequency;
	if (sum >= limit)
	  return true;


r~


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