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

`-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. Bash脚本中的操作符

    一.文件測试操作符 假设以下的条件成立将会返回真. -e 文件存在 -a 文件存在 这个选项的效果与-e同样. 可是它已经被"弃用"了, 而且不鼓舞使用. -f 表示这个文件是一个 ...

  2. 【转】如何在Mac 终端升级ruby版本

    原文网址:https://segmentfault.com/a/1190000003784636 rvm是什么?为什么要安装rvm呢,因为rvm可以让你拥有多个版本的Ruby,并且可以在多个版本之间自 ...

  3. Java-杂项:Java数组Array和集合List、Set、Map

    ylbtech-Java-杂项:Java数组Array和集合List.Set.Map 1.返回顶部 1. 之前一直分不清楚java中的array,list.同时对set,map,list的用法彻底迷糊 ...

  4. JavaScript-Tool:md5.js

    ylbtech-JavaScript-Tool:md5.js 1.返回顶部 1.md5.js /* CryptoJS v3.1.2 code.google.com/p/crypto-js (c) 20 ...

  5. ROS-Gazebo-turtlebot3仿真

    前言:Gazebo是一款强大的3D仿真器,支持机器人开发所需的机器人.传感器和环境模型,并且通过搭载的物理引擎可以得到逼真的仿真结果.即便Gazebo是一款开源仿真器,却具有高水准的仿真性能,因此在机 ...

  6. C语言-统计数字、字母、特殊字符

    Action() { //统计字符019aBcd8***,4,4,3 int i,z,t; char *str="019aBcd8***"; fun_Count(str,i,z,t ...

  7. Unity 导入的模型检测不到碰撞

    解决方案 添加Mesh Collider和rigidbody,并且Collider里边2个勾要勾上. 这是我碰到的问题.如果没解决你的问题,别打我,逃~

  8. CentOS 7.5安装pycharm

    环境 安装环境: windows 10 Pro CentOS Linux release 7.6.1810 (Core) VMWare Workstation 15 Pro 安装图形化界面包 首先更新 ...

  9. C语言基本语法——函数

    1.什么是函数 2.函数语法 3.函数声明 4.函数调用 5.函数的形参与实参 6.return与exit关键字 7.递归函数 1.什么是函数 • 函数就是一连串语句被组合在一起,并指定了一个名字 • ...

  10. [NOIP补坑计划]NOIP2016 题解&做题心得

    感觉16年好难啊QAQ,两天的T2T3是不是都放反了啊…… 场上预计得分:100+80+100+100+65+100=545(省一分数线280) ps:loj没有部分分,部分分见洛咕 题解: D1T1 ...