What's the difference between the /Ot
flag ("favor fast code") and the /O2
flag ("maximize speed")?
(Ditto with /Os
and /O1
.)
-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.
The /O1 and /O2 compiler options are a quick way to set several specific optimization options at once. The /O1 option sets the individual optimization options that create the smallest code in the majority of cases. The /O2 option sets the options that create the fastest code in the majority of cases.
-O3 instructs the compiler to optimize for the performance of generated code and disregard the size of the generated code, which might result in an increased code size. It also degrades the debug experience compared to -O2 .
Compiler flags are options you give to gcc when it compiles a file or set of files. You may provide these directly on the command line, or your development tools may generate them when they invoke gcc.
/O1 and /O2 bundle together a number of options aimed at a larger goal. So /O1 makes a number of code generation choices that favour size; /O2 does the same thing and favours speed.
/O1 includes /Os as well as other options. /O2 includes /Ot as well as other options. Some optimisations are enabled by both /O1 and /O2. And, depending on your program's paging behaviour, /O1 (size) can result in faster speed than /O2 if paging code comes to dominate your perf over instruction execution cost.
A good short summary of the impact of /O1 and /O2 in VC++ 2010 is here
http://msdn.microsoft.com/en-us/library/8f8h5cxt.aspx
and includes links for other versions of VC.
Martyn
See the /O1, /O2 (Minimize Size, Maximize Speed) article at MSDN.
It states that /O2
is equivalent to:
/Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy
So /O2
enables all the things that /Ot
does, and some more. Same thing for /O1
vs. /Os
, but for size this time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With