gcc原文网址:https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Optimize-Options.html#Optimize-Options

-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 -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, -frename-registers and -funswitch-loops options. 

-O0

Do not optimize. This is the default. 

-Os

Optimize for size. -Os enables all -O2 optimizations that do not typically increase code size. It also performs further optimizations designed to reduce code size.

-Os disables the following optimization flags:

          -falign-functions  -falign-jumps  -falign-loops -falign-labels  -freorder-blocks  -fprefetch-loop-arrays

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

gcc优化等级-O0 -O1 -O2 -Os -O3相关推荐

  1. #gcc笔记01#gcc编译选项 -O0 -O1 -O2 -O3

    -O0 -O1 -O2 -O3 编译器的优化选项的4个级别,-O0表示没有优化,-O1为缺省值,-O3优化级别最(此处为大写字母O) 优化选项(来源:http://blog.csdn.net/Sodi ...

  2. 《编译 - 编译杂记》GCC优化等级说明

    GCC提供了大量的优化选项,通过不同的参数可以对编译时间.目标文件大小.执行效率三个维度进行平衡,不同的GCC版本器优化等级略有不同,笔者本文以GCC 7.5为例进行说明. 最新的版本是GCC 11. ...

  3. 【gcc】gcc优化等级 -O1 -O2 -O3 -Os -Ofast -Og

    目录 优化等级 -O1 -O2 -O3 -Os -Ofast -Og cmake 生成 debug和 release 版|Cmake设置优化等级 优化等级 -O1 -O2 -O3 -Os -Ofast ...

  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.chinaunix.net/uid-24954950-id-2956476.html 相关博客http://blog.csdn.net/misiter/article/ ...

  6. makefile工作笔记0002---gcc -O0 -O1 -O2 -O3 四级优化选项及每级分别做什么优化

    技术交流QQ群[JAVA,C++,Python,.NET,BigData,AI]:170933152 相关博客http://blog.chinaunix.net/uid-24954950-id-295 ...

  7. Makefile 中 -wl ,rpath 以及 O0 O1 O2 O3 Os 的用法

    再makefile中一般默认的 lib 的加载路径是/lib /usr/lib  如果想要改变程序运行时的libs的加载路径 就需要用到 -wl , rpath 参数来添加lib 加载路径. O0 O ...

  8. GNU编译优化级别-O -O1 -O2 -O3

    最近做一个算法的GPU加速,发现实际上使用gcc的-O3(最高级编译优化)选项,可以获得很高的加速比,我的程序里达到了3倍的样子,有时效果甚至比GPU加速好.因此小小学习了下GNU的编译优化. 附言一 ...

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

    Gcc 编译优化简介 gcc 提供了为了满足用户不同程度的的优化需要,提供了近百种优化选项,用来对{编译时间,目标文件长度,执行效率}这个三维模型进行不同的取舍和平衡.优化的方法不一而足,总体上将有以 ...

最新文章

  1. grafana官方使用文档_可视化监控展示工具之Grafana,安装部署和使用
  2. ML之XGBoost:XGBoost参数调优的优秀外文翻译—《XGBoost中的参数调优完整指南(带python中的代码)》(四)
  3. 手脱EZIP v1.0
  4. SparkMLlib分类算法之决策树学习
  5. WIN10系统和压缩内存占用磁盘过高的解决方案(亲测有效)
  6. 获取数据库链接Junit
  7. 桌面计算机主流硬盘接口,M.2、U.2谁更好?主流硬盘接口大扫盲
  8. osql 登陆mysql_命令行登录mysql报Segmentation fault故障解决
  9. python实现文件压缩
  10. 计算机及格人数函数公式大全,excel函数计算及格人数和合格人数
  11. 【烈日炎炎战后端】JAVA多线程(11.2万字)
  12. CRM 安装不规范,亲人两行泪
  13. mysql数据库木马查杀_服务器木马后门怎么查杀
  14. 联想笔记本拯救者Y7000盒盖不休眠问题,Win10
  15. [附源码]Node.js计算机毕业设计二手书交易软件设计与实现Express
  16. 海量向量搜索引擎 Milvus 开源啦
  17. freemarker 遍历 map
  18. BFGS算法(Broyden-Fletcher-Goldfarb-Shanno算法)
  19. KMP算法: Oulipo
  20. 快乐AK场2 E 删删删越小越好 单调栈

热门文章

  1. 数据基础---mysql数据库操作(二)---JOIN用法
  2. HCIP——IPV4和IPV6共存
  3. 如何获得个人免费空间
  4. STM32实战 1 | STM32Cube生态系统认识与介绍
  5. 计算机专业血压高影响录取吗,男性患者,58岁,电脑工程师。发现血压升高6年,血脂增高1个月。患者6年前在例行体检时发现血压升高, - 赏学吧...
  6. python 三维矩阵乘以二维矩阵_如何将一个二维数组和一个三维数组矩阵相乘得到一个三维数组?...
  7. 打造网络营销利器-第2篇--友情链接交换-网站优化进阶
  8. GNSS一些基础知识(自用,批判地看)
  9. 怎样才是正确的线程启动方式?
  10. E. String Reversal