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

送分小仙女□ 提交于 2020-01-02 02:53:08

问题


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

(Ditto with /Os and /O1.)


回答1:


/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




回答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.




回答3:


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

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



来源:https://stackoverflow.com/questions/6007378/visual-c-compiler-optimization-flags-difference-between-o2-and-ot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!