Chinaunix首页 | 论坛 | 博客
  • 博客访问: 568442
  • 博文数量: 169
  • 博客积分: 2656
  • 博客等级: 少校
  • 技术积分: 1685
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-30 13:03
文章分类

全部博文(169)

文章存档

2011年(1)

2010年(135)

2009年(33)

我的朋友

分类: 嵌入式

2010-05-20 23:27:19

.-O2是最常用的一个优化选项,也是缺省的优化选项,建议使用它.过度优化会使调试和出问题后的堆栈分析变得麻烦,未必是件好事.
-O1 Optimize. Optimizing compilation takes somewhat more time, and a lot more
    memory for a large function.
    With ‘-O’, the compiler tries to reduce code size and execution time, without
    performing any optimizations that take a great deal of compilation time.
    ‘-O’ turns on the following optimization flags:
        -fdefer-pop
        -fmerge-constants
        -fthread-jumps
        -floop-optimize
        -fif-conversion
        -fif-conversion2
        -fdelayed-branch
        -fguess-branch-probability
        -fcprop-registers
    ‘-O’ also turns on ‘-fomit-frame-pointer’ on machines where doing so does
    not interfere with debugging.
-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.
    ‘-O2’ turns on all optimization flags specified by ‘-O’. It also turns on the
    following optimization flags:
        -fforce-mem
        -foptimize-sibling-calls
        -fstrength-reduce
        -fcse-follow-jumps -fcse-skip-blocks
        -frerun-cse-after-loop -frerun-loop-opt
        -fgcse -fgcse-lm -fgcse-sm -fgcse-las
        -fdelete-null-pointer-checks
        -fexpensive-optimizations
        -fregmove
        -fschedule-insns -fschedule-insns2
        -fsched-interblock -fsched-spec
        -fcaller-saves
        -fpeephole2
        -freorder-blocks -freorder-functions
        -fstrict-aliasing
        -funit-at-a-time
        -falign-functions -falign-jumps
        -falign-loops -falign-labels
        -fcrossjumping
        Please note the warning under ‘-fgcse’ about invoking ‘-O2’ on programs that
        use computed gotos.
-O3 Optimize yet more. ‘-O3’ turns on all optimizations specified by ‘-O2’ and
    also turns on the ‘-finline-functions’, ‘-fweb’ and ‘-frename-registers’
    options.
-O0 Do not optimize. This is the default.


对于-O3新增的三个优化选项:

-finline-functions
    Integrate all simple functions into their callers. The compiler heuristically decides
    which functions are simple enough to be worth integrating in this way.
    If all calls to a given function are integrated, and the function is declared
    static, then the function is normally not output as assembler code in its own
    right.
    Enabled at level ‘-O3’.
-fweb
    Constructs webs as commonly used for register allocation purposes and assign
    each web individual pseudo register. This allows the register allocation pass
    to operate on pseudos directly, but also strengthens several other optimization
    passes, such as CSE, loop optimizer and trivial dead code remover. It can,
    however, make debugging impossible, since variables will no longer stay in a
    “home register”.
    Enabled at levels ‘-O3’.
-frename-registers
    Attempt to avoid false dependencies in scheduled code by making use of registers
    left over after register allocation. This optimization will most benefit
    processors with lots of registers. It can, however, make debugging impossible,
    since variables will no longer stay in a “home register”.
阅读(480) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~