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 <hubi...@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