2

使用 gcc 时,是否可以在不指定 -O 级别的情况下启用单个优化标志?

gcc -ffasst-math foo.c

或者

gcc -O1 -ffast-math foo.c

哪一个有效?谢谢!

4

1 回答 1

0

是的,您可以启用单独的优化标志。

来自 gcc 手册页的信息:

-O

-O 打开以下优化标志:

-fauto-inc-dec -fcprop-registers -fdce -fdefer-pop -fdelayed-branch -fdse -fguess-branch-probability -fif-conversion2 -fif-conversion -finline-small-functions -fipa-pure-const -fipa -reference -fmerge-constants -fsplit-wide-types -ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-fre -ftree-sra -ftree-ter -funit-at-a-time

-O 还会在不干扰调试的机器上打开 -fomit-frame-pointer。

-ffast-数学

设置 -fno-math-errno、-funsafe-math-optimizations、-ffinite-math-only、-fno-rounding-math、-fno-signaling-nans 和 -fcx-limited-range。此选项导致定义预处理器宏“ FAST_MATH ”。

任何 -O 选项都不会打开此选项,因为它可能导致依赖于数学函数的 IEEE 或 ISO 规则/规范的精确实现的程序的错误输出。但是,对于不需要这些规范保证的程序,它可能会产生更快的代码。

于 2012-03-30T12:44:24.027 回答