GCC优化选项:一般的文档里不容易找到的-Os
2010-05-06 16:29
239 查看
在研究编译驱动的makefile的时候,发现GCC的命令行里面有一个-Os的优化选项。
遍查GCC文档,发现了-O0, -O1, -O2, -O3,就是没有发现-Os。
祭出GOOGLE大法搜了一下,终于发现这篇文章说明了-Os的作用: http://www.linuxjournal.com/article/7269
原来-Os相当于-O2.5。是使用了所有-O2的优化选项,但又不缩减代码尺寸的方法。
详细的说明如下:
Level 2.5 (-Os)
The special optimization level (-Os or size) enables all -O2 optimizations that do not increase code size; it puts the emphasis on size over speed. This includes all second-level optimizations, except for the alignment optimizations. The alignment optimizations skip space to align functions, loops, jumps and labels to an address that is a multiple of a power of two, in an architecture-dependent manner. Skipping to these boundaries can increase performance as well as the size of the resulting code and data spaces; therefore, these particular optimizations are disabled. The size optimization level is enabled as:
In gcc 3.2.2, reorder-blocks is enabled at -Os, but in gcc 3.3.2 reorder-blocks is disabled.
==============================
补充:在GCC的官方文档里又发现了关于-Os的说明: http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Optimize-Options.html#Optimize-Options
遍查GCC文档,发现了-O0, -O1, -O2, -O3,就是没有发现-Os。
祭出GOOGLE大法搜了一下,终于发现这篇文章说明了-Os的作用: http://www.linuxjournal.com/article/7269
原来-Os相当于-O2.5。是使用了所有-O2的优化选项,但又不缩减代码尺寸的方法。
详细的说明如下:
Level 2.5 (-Os)
The special optimization level (-Os or size) enables all -O2 optimizations that do not increase code size; it puts the emphasis on size over speed. This includes all second-level optimizations, except for the alignment optimizations. The alignment optimizations skip space to align functions, loops, jumps and labels to an address that is a multiple of a power of two, in an architecture-dependent manner. Skipping to these boundaries can increase performance as well as the size of the resulting code and data spaces; therefore, these particular optimizations are disabled. The size optimization level is enabled as:
gcc -Os -o test test.c
In gcc 3.2.2, reorder-blocks is enabled at -Os, but in gcc 3.3.2 reorder-blocks is disabled.
==============================
补充:在GCC的官方文档里又发现了关于-Os的说明: http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Optimize-Options.html#Optimize-Options
相关文章推荐
- GCC优化选项:一般的文档里不容易找到的-Os
- gcc 优化选项 -O1 -O2 -O3 -Os 优先级,-fomit-frame-pointer
- gcc 优化选项 -O1 -O2 -O3 -Os 优先级,-fomit-frame-pointer
- gcc 优化选项 -O1 -O2 -O3 -Os 优先级,-fomit-frame-pointer .
- gcc 优化选项 -O1 -O2 -O3 -Os 优先级,-fomit-frame-pointer
- gcc 优化选项 -O1 -O2 -O3 -Os 优先级,-fomit-frame-pointer
- gcc 优化选项 -O1 -O2 -O3 -Os 优先级
- gcc 优化选项 -O1 -O2 -O3 -Os 优先级,
- gcc 优化选项 -O1 -O2 -O3 -Os 优先级,-fomit-frame-pointer
- GCC 优化选项 -O1 -O2 -O3 -Os 优先级,-fomit-frame-pointer
- gcc 优化选项 -O1 -O2 -O3 -Os 优先级
- gcc 优化选项 -O1 -O2 -O3 -Os 优先级,-fomit-frame-pointer
- gcc 优化选项 -O1 -O2 -O3 -Os 优先级,-fomit-frame-pointer .
- GCC编译器选项及优化提示
- gcc 编译优化选项
- gcc -O优化选项
- gcc 的部分优化选项
- 转:GCC笔记(警告.优化以及调试选项)
- GCC编译器选项及优化提示
- GCC优化选项简单说明