Conversation

Is there a document somewhere that describes what optimizations PGO opens up? Like I imagine it can say "don't inline this, it doesn't get called" and "inline this, it gets called a bunch", but what else?
1
2
Replying to
It provides branch metadata so it knows how to order branches or add hints for better branch prediction. Can also decide when to use cmov, etc. that way. Since it has metadata on function call sites, callees and branches it can also split out functions into hit/cold regions, etc.
2
Replying to
Is there a doc with all of this? I actually don't even know how code tells a branch predictor "this is the likely branch", although I know that gcc had a 'likely' builtin iirc. I see you mentioned a builtin, I'll check that out too.
1
Replying to and
You can see the difference yourself by marking a branch as likely and then unlikely and looking at the disassembled optimized code. It will tend to put all the cold paths at the bottom of the function or if it's really smart could even hoist them into their own functions, etc.
1
1
Replying to and
It will optimize the cold blocks / functions for size and try to group them in cold sections together, and similarly will try to group hot code together. PGO can provide more information it could use beyond just hot/cold to group code that's used together in sections together.
1
1
Show replies