gpt4 book ai didi

c++ - gcc -O2 的含义

转载 作者:IT老高 更新时间:2023-10-28 23:22:17 26 4
gpt4 key购买 nike

我在 makefile 中经常看到这个标志。什么意思,什么时候用?

最佳答案

优化级别 2。

来自 GCC 手册页:

-O1 Optimize. Optimizing compilation takes somewhat more time, and a lotmore memory for a large function.

-O2 Optimize even more. GCC performs nearly all supported optimizationsthat do not involve a space-speedtradeoff. The compiler does notperform loop unrolling or functioninlining when you specify -O2. Ascompared to -O, this option increasesboth compilation time and theperformance of the generated code.

-O3 Optimize yet more. -O3 turns on all optimizations specified by -O2 andalso turns on the -finline-functions,-funswitch-loops, -fpredictive-commoning, -fgcse-after-reload and -ftree-vectorize options.

-O0 Reduce compilation time and make debugging produce the expectedresults. This is the default.

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

关于c++ - gcc -O2 的含义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/655382/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com