Rate This Document
Findability
Accuracy
Completeness
Readability

Optimization Principles

Traditional compilation optimization can only predict the execution behavior of programs through static program analysis and heuristic algorithms. By collecting program runtime information, PGO can accurately determine the cold, hot, and execution probability of code. In this way, PGO can efficiently optimize cold and hot partitioning, branch prediction, function rearrangement, register allocation, vectorization, and function inline, improving the cache hit ratio, branch hit ratio, and data parallelism, and reducing the pressure on the register.

The typical optimization principles are described as follows:

Hot/Cold Partitioning

Cold branches are removed to aggregate hot code and improve the cache hit ratio.

Function Rearrangement

Code section functions are rearranged to aggregate hotspot functions and reduce iTLB and iCache miss rates.

Branch Prediction

Branch sequence is adjusted to reduce the branch miss rate.

Function Inline

Feedback-based inline: global analysis, precise inline, optimized call stack, and better memory allocation.

Switch Optimization

Structure branches are adjusted to reduce jumps and the branch miss rate.