This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Branch prediction
- From: Andrew Haley <aph at redhat dot com>
- To: Raphael Clifford <raphael at clifford dot net>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, gcc at gcc dot gnu dot org
- Date: Thu, 30 May 2013 15:06:19 +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> <CAFHc1Qb0HWWg-wuZae8RASMgi9b7Jdw7sCy-38VSqmOUq5mPKA at mail dot gmail dot com>
On 05/30/2013 03:03 PM, Raphael Clifford wrote:
> 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?
Most commonly, moving unlikely branches to the end of a function.
Andrew.