Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What information does GCC Profile Guided Optimization (PGO) collect and which optimizations use it?

Tags:

c++

gcc

pgo

lto

Which information does GCC collect when I enable -fprofile-generate and which optimization does in fact uses the collected information (when setting the -fprofile-use flag) ?

I need citations here. I've searched for a while but didn't found anything documented.

Information regarding link-time optimization (LTO) would be a plus! =D

like image 395
JohnTortugo Avatar asked Dec 14 '12 15:12

JohnTortugo


People also ask

What does GCC optimization do?

The compiler optimizes to reduce the size of the binary instead of execution speed. If you do not specify an optimization option, gcc attempts to reduce the compilation time and to make debugging always yield the result expected from reading the source code.

What does O2 optimization do?

-O2 Optimize even more. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. The compiler does not perform loop unrolling or function inlining when you specify -O2. As compared to -O, this option increases both compilation time and the performance of the generated code.

What is PGO in programming?

Profile-guided optimization (PGO) lets you optimize a whole executable file, where the optimizer uses data from test runs of the .exe or . dll file. The data represents the likely performance of the program in a production environment.

How many optimization levels are there in GCC?

6.4 Optimization levels. In order to control compilation-time and compiler memory usage, and the trade-offs between speed and space for the resulting executable, GCC provides a range of general optimization levels, numbered from 0--3, as well as individual options for specific types of optimization.


1 Answers

-fprofile-generate enables -fprofile-arcs, -fprofile-values and -fvpt.

-fprofile-use enables -fbranch-probabilities, -fvpt, -funroll-loops, -fpeel-loops and -ftracer

Source: http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Optimize-Options.html#Optimize-Options

PS. Information about LTO also on that page.

like image 102
chill Avatar answered Oct 18 '22 19:10

chill