Re: [patch 00/2] improve .text size on gcc 4.0 and newer compilers

Daniel Jacobowitz
2006-01-05T18:43:14Z

On Thu, Jan 05, 2006 at 08:55:27AM -0800, Linus Torvalds wrote:
>
>
> On Thu, 5 Jan 2006, Jakub Jelinek wrote:
> > >
> > > I wonder if gcc can be convinced to put all unlikely() code sections
> > > into a .text.rare as well, that'd be really cool.
> >
> > gcc 4.1 calls them .text.unlikely and you need to use
> > -freorder-blocks-and-partition
> > switch. But I haven't been able to reproduce it on a short testcase I
> > cooked up, so maybe it is broken ATM (it put the whole function into
> > .text rather than the expected part into .text.unlikely and left
> > empty .text.unlikely).
>
> If it causes the conditional jump to become a long one instead of a byte
> offset one, it's actually a pessimisation for no gain (yes, it might give
> better cache density _if_ the function that is linked after the current
> one is cache-dense with the function in question and _if_ the unlikely
> sequence is really really unlikely, but that's two fairly big ifs).
>
> So I'm not at all convinced of the feature (or maybe gcc actually does the
> right thing, and the reason you can't reproduce it is because gcc is being
> understandably reluctant to use the other section).

It triggers either rarely or never in basic compilation; it's designed
to work off profile feedback. With that it worked in gcc 4.1 a couple
of weeks ago.

--
Daniel Jacobowitz
CodeSourcery