Visual C++ Compiler Optimization Flags: Difference Between /O2 and /Ot
Asked Answered
L

3

8

What's the difference between the /Ot flag ("favor fast code") and the /O2 flag ("maximize speed")?

(Ditto with /Os and /O1.)

Lode answered 15/5, 2011 at 8:39 Comment(1)
Next you'll want to know the answer to this: What is the difference between the /Ox and /O2 compiler options? ;-)Hurrah
B
10

/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

Broderic answered 15/5, 2011 at 8:47 Comment(2)
Thanks for the response, but a question: So what happens if I put /O1 with /Ot? Is it favoring size or speed?Lode
If you put /O1 and then /Ot in that order (and no subsequent options or pragmas), you get all the other options in O1 and /Os from /O1 is removed and /Ot replaces it. What you then get is a hybrid of size and speed optimisations.Broderic
A
2

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.

Algid answered 15/5, 2011 at 8:47 Comment(0)
S
0

No difference. /Ot is a part of the /O2 optimizations.

http://msdn.microsoft.com/en-us/library/f9534wye.aspx

Septum answered 15/5, 2011 at 8:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.