-O3比-O2还慢?

flamingheart 2006-05-22 09:34:38
我的一个程序
用这个选项
g++ -O3 -fomit-frame-pointer -funroll-loops -fPIC -Wno-deprecated -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
为什么比用这个选项
g++ -g -O2 -Wno-deprecated -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
还要慢呢?
...全文
255 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
x86 2006-05-23
  • 打赏
  • 举报
回复
`-funroll-loops'
Unroll loops whose number of iterations can be determined at
compile time or upon entry to the loop. `-funroll-loops' implies
both `-fstrength-reduce' and `-frerun-cse-after-loop'. This
option makes code larger, and may or may not make it run faster.


这个选项作为例子可以知道,有的优化选项并不是总能使速度变快。你可以用info gcc看看各个优化选项的帮助。
x86 2006-05-23
  • 打赏
  • 举报
回复
`-O3' turns on all optimizations specified by
`-O2' and also turns on the `-finline-functions', `-fweb',
`-funit-at-a-time', `-ftracer', `-funswitch-loops' and
`-frename-registers' options.

也就是说O3比O2多了上面那些选项,你可以试着在O2的基础上加上其中的一些选项,看看最后到底是哪个选项造成速度更慢。

23,121

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧