This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: code growth
- To: Jan Hubicka <jh at suse dot cz>
- Subject: Re: code growth
- From: Richard Henderson <rth at redhat dot com>
- Date: Fri, 24 Aug 2001 11:05:26 -0700
- Cc: gcc-patches at gcc dot gnu dot org, patches at x86-64 dot org
- References: <20010822213521.H30704@atrey.karlin.mff.cuni.cz> <20010822131218.L29601@redhat.com> <20010823154859.B4372@atrey.karlin.mff.cuni.cz> <20010823161148.C30701@redhat.com> <20010824153135.G18853@atrey.karlin.mff.cuni.cz>
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~