四种编译优化类型的解释:

`-O ' 
`-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    
                               -fdelayed-branch    
                               -fguess-branch-probability    
                               -fcprop-registers    
                               -floop-optimize    
                               -fif-conversion    
                               -fif-conversion2    
                               -ftree-ccp    
                               -ftree-dce    
                               -ftree-dominator-opts    
                               -ftree-dse    
                               -ftree-ter    
                               -ftree-lrs    
                               -ftree-sra    
                               -ftree-copyrename    
                               -ftree-fre    
                               -ftree-ch    
                               -funit-at-a-time    
                               -fmerge-constants 
  
                `-O '   also   turns   on   `-fomit-frame-pointer '   on   machines   where   doing 
                so   does   not   interfere   with   debugging. 
  
                `-O '   doesn 't   turn   on   `-ftree-sra '   for   the   Ada   compiler.      This 
                option   must   be   explicitly   specified   on   the   command   line   to   be 
                enabled   for   the   Ada   compiler. 
  
`-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: 
                               -fthread-jumps    
                               -fcrossjumping    
                               -foptimize-sibling-calls    
                               -fcse-follow-jumps      -fcse-skip-blocks    
                               -fgcse      -fgcse-lm       
                               -fexpensive-optimizations    
                               -fstrength-reduce    
                               -frerun-cse-after-loop      -frerun-loop-opt    
                               -fcaller-saves    
                               -fpeephole2    
                               -fschedule-insns      -fschedule-insns2    
                               -fsched-interblock      -fsched-spec    
                               -fregmove    
                               -fstrict-aliasing    
                               -fdelete-null-pointer-checks    
                               -freorder-blocks      -freorder-functions    
                               -falign-functions      -falign-jumps    
                               -falign-loops      -falign-labels    
                               -ftree-vrp    
                               -ftree-pre 
  
                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 ', 
                `-funswitch-loops '   and   `-fgcse-after-reload '   options. 
  
`-O0 ' 
                Do   not   optimize.      This   is   the   default.

还有个常用的优化选项: -Os

它相当于-O2.5。是使用了所有-O2的优化选项,但又不缩减代码尺寸的方法。

参考文档: https://www.linuxjournal.com/article/7269

https://www.cnblogs.com/dylancao/p/9528432.html

GCC 优化选项 -O1 -O2 -O3 -OS 优先级,-FOMIT-FRAME-POINTER(O3的优化很小,只增加了几条优化而已)的更多相关文章

  1. gcc 优化选项 -O1 -O2 -O3 -Os 优先级

    http://hi.baidu.com/xiaole10368/item/7cea9b1369cc240db88a1a5c 少优化->多优化: O0 -->> O1 -->&g ...

  2. gcc 优化选项 -O1 -O2 -O3 -Os 优先级,-fomit-frame-pointer

    英文:https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Optimize-Options.html#Optimize-Options 少优化->多优化: ...

  3. 警惕arm-linux-gcc编译器优化选项

    arm-linux-gcc的优化选项例如(-O2),可以加速我们的程序,使程序执行效率更高.但是,倘若我们就是需要程序慢一点运行,但是优化却把我们的延时函数优化的没有了的时候,这种优化却不是我们想要的 ...

  4. gcc -O0 -O1 -O2 -O3 四级优化选项及每级分别做什么优化【转】

    转自:http://blog.csdn.net/qinrenzhi/article/details/78334677 相关博客http://blog.chinaunix.net/uid-2495495 ...

  5. gcc -O0 -O1 -O2 -O3 四级优化选项及每级分别做什么优化

    参考链接 : http://blog.csdn.net/qq_31108501/article/details/51842166 gcc -D选项的作用,声明宏 参考链接:  http://blog. ...

  6. gcc/g++ -O 优化选项说明

    查查gcc手册就知道了,每个编译选项都控制着不同的优化选项 下面从网络上copy过来的,真要用到这些还是推荐查阅手册 -O设置一共有五种:-O0.-O1.-O2.-O3和-Os. 除了-O0以外,每一 ...

  7. gcc options选项的优化及选择

    gcc options选项的优化 -c和-o都是gcc编译器的可选参数[options] -c表示只编译(compile)源文件但不链接,会把.c或.cc的c源程序编译成目标文件,一般是.o文件.[只 ...

  8. GCC优化选项-fomit-frame-pointer对于esp和ebp优化的作用

    我的博客:www.while0.com -fomit-frame-pointer选项是发布产品时经常会用到的优化选项,它可以优化汇编函数中用edp协助获取堆栈中函数参数的部分,不使用edp,而是通过计 ...

  9. Object.assign(o1, o2, o3) 对象 复制 合拼

    Object 对象方法学习之(1)—— 使用 Object.assign 复制对象.合并对象 合并对象 var o1 = {a: 1}; var o2 = {b: 2}; var o3 = {c: 3 ...

随机推荐

  1. java 中的静态(static)代码块

    类字面常量 final 静态域不会触发类的初始化操作 非 final static 静态域(以及构造器其实是一种隐式的静态方法) Class.forName():会自动的初始化: 使用 .class来 ...

  2. ROS-Rviz-turtlebot3仿真信息查看

    前言:Rviz是ROS自带的一种3D可视化工具. 一.安装turtlebot3功能包 1.1 安装依赖包 sudo apt-get install ros-kinetic-joy ros-kineti ...

  3. Spring《五》集合的注入方式

    List.Set.Map.Properties 1.List <property name="msg"> <list> <value>gf< ...

  4. javascript中手风琴特效

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  5. DirectUI界面编程(三)从XML文件中加载界面

    Duilib支持xml界面布局,使得界面设计与逻辑处理相分离,本节介绍如何从xml文件中加载界面元素. 我们需要以下几个步骤: 创建并初始化CPaintManagerUI对象. 创建CDialogBu ...

  6. Android 给WebView设置Cookie

    最近项目中用到WebView访问新浪支付页面,有个要求是必须是登录状态,否则会报Token过期,然后我简单的将我从cookie中取得的ticket,即一串数字可以代表用户登录的唯一标识作为参数拼接到u ...

  7. 微信小程序遇坑笔记

    最近做了一个简单的微信小程序,遇到了一些坑: 1.appid固定,但是appsecret是可以变的,而且没有地方查看,后台以查看就是变更了,所以这个地方在开发的时候需要保存好: 2.打开网页,这个网页 ...

  8. APUE学习笔记7——进程间通信

    1 管道 管道一般是一种半双工的进程间通信方式,只能够在具有公共祖先的进程之间使用,比如一个管道由一个进程创建,然后该进程调用fork,之后父.子进程就可以使用该管道. 管道是调用pipe函数创建的. ...

  9. 01《UML大战需求分析》阅读笔记之一

    在大二的时候就已经在课堂上对UML也就是统一建模语言有了初步的了解,但是却不怎么明白,虽然可以画图可以完成任务,但是有些糊里糊涂.所以特地把这门书作为精读书籍,想要更加深度地学习UML.很多内容只用语 ...

  10. Unity 向量点乘、叉乘

    向量点乘计算角度,向量叉乘计算方位 a,b为向量 点乘计算公式:a x b = |a| x |b| x cosθ 叉乘计算公式:a x b = |a| x |b| x sinθ