This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Branch prediction
- From: Raphael Clifford <raphael at clifford dot net>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 30 May 2013 15:03:09 +0100
- Subject: Re: Branch prediction
- References: <CAFHc1Qb0UqZaCwxQFLjmXSu7g+7Qmy1vEkHwBUtfcR-CHaLs5g at mail dot gmail dot com> <20130530134520 dot GB15456 at atrey dot karlin dot mff dot cuni dot cz>
Thank you for this. My question was about something more specific
however. I am interested specifically in branch prediction. For
example one could add __builtin_expect or the compiler can use the
information it finds in its profiling. How is this information used
by gcc to provide optimised assembly (for a modern Pentium)?
One option could be to lay out more likely paths differently or even
perhaps to reorder conditional statements where that is valid but what
does gcc do and does it actually help?
Raphael
On 30 May 2013 14:45, Jan Hubicka <hubicka@ucw.cz> wrote:
>> Is there any documentation for what gcc does with branch prediction
>> information it gets from profiling? I am interested in this for
>> modern Pentium processors where you can no longer give hints.
>
> The profile feedback drives optimizations (i.e. decision what to optimize for
> speed and what for size or if it is worth to pesimize one path through program
> helping another) and it also affects code layout. Somewhat old writeups are at
> http://www.ucw.cz/~hubicka/papers/proj.pdf and
> http://gccsummit.org/2005/2005-GCC-Summit-Proceedings.pdf#page=113 These are
> still +- accurate to what is happening. Number of optimizations driven by the
> profile grew over the years. For example, we now enable aggressive inlining,
> vectorization, loop unrolling/peeling and other fancy stuff on parts of program
> we know is important by the feedback.
>
> Honza
>>
>> Specifically I am interested in whether there are in fact any
>> optimisations that work reliably from this information.
>>
>> Raphael