About Profile Guided Optimization (PGO)

Profile-guided optimization (PGO) provides dynamic program control flow information to the compiler. The compiler uses this information to make better decisions for many optimizations such as long/short trip count loops, inlining functions and more.

PGO also deals with unbalanced if statements, taking into consideration the number of instructions and the probability of a branch being taken.

Pros
Using PGO can lead to better:
  • predication
  • speculation
  • function splitting
  • loop optimizations
  • pipelining vs. unroll vs. nothing
  • basic block ordering
  • better decisions of which functions to inline
  • better register allocation
  • option statement optimization
  • function ordering

Cons

  • different paradigm for builds - three steps
  • requires you to schedule time in final stages of development when code is more stable
  • requires a representative workload-not for specialized case