GCC multiple optimization flags

丶灬走出姿态 提交于 2020-05-14 14:38:09

问题


I have some legacy code that compiles with both -02 and -03 set. From the GCC man file I get the guarantee that:

-O3 turns on all optimizations specified by -O2 and also turns on the -finline-functions, -funswitch-loops, -fpredictive-commoning, -fgcse-after-reload and -ftree-vectorize options.

So, at first glance it would seem likely that turning both of these flags on would be the same as just -O3. However, that got me thinking is that the right thing to do in that case as -O2 is probably the "safer" option. Obviously, it is a simple matter compile some code with all of the permutations and see what happens in each case, but I was wondering if anyone knows if there is a specific policy that GCC has in regard to specifying multiple optimizations levels and if so what is the reasoning behind it?


回答1:


From the man page:

If you use multiple -O options, with or without level numbers, the last such option is the one that is effective.



来源:https://stackoverflow.com/questions/5557261/gcc-multiple-optimization-flags

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