-o0
-o1
-o2
-o3
4 levels of compiler optimization options,-o0 means no optimizations,-o1 defaults,-O3 optimization level most (here is Capital letter O)
Optimization Options (Source: http://blog.csdn.net/Sodier/article/details/452566)
This part of the content can be divided into two parts, part of this is to have the compiler analyze the code, and the other part is that we can make some information about the hardware for the compiler, and let him generate better code for the hardware, and we have to compile the program with the source code, in many cases, is for this reason.
First look at code optimization, from the overall optimization of code, GCC provides the following options
-o–o1
The two options have the same meaning, GCC will perform optimizations that reduce code size and execution time, and this level of optimization will not be performed for optimization options that can severely impact compilation time.
-o2
At this level GCC will provide all of the supported optimizations, but this does not include a space-time optimization, such as a compiler that does not use loop expansion and function inline. This option further speeds up the performance of compilation time and code generation compared to-O.
-o3
In addition to the optimization options provided by-o2, the-finline-functions,-funswitch-loops and-fgcse-afer-reload options are specified, with the goal of only one effort to perform code optimization.
-os
This option is specifically designed to optimize code size, and-os opens an optimization option that does not significantly increase code size in all-O2 levels
-o0
This option represents not performing optimizations
The point here is that although GCC provides the 4 overall optimization options for 1~3 and S, but from the actual optimization effect, often O3 optimization of the program is not the highest efficiency, and most of the cases we are using-O2, if you want to achieve the highest efficiency benefits, then may wish to try these 4 options. In addition, these options are simply a combination of many of the unilateral optimizations provided by GCC, and if you want to know more about the specifics of the optimization, you can go to the GCC Manual for space limitations. The last thing to keep in mind is that if your program is for high-precision numerical calculations, then remember not to use any of the optimization options above.