最終更新:2019-09-18 (水) 17:41:03 (1679d)  

GCC/最適化
Top / GCC / 最適化

https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

gcc -O

gcc -Os

  • Optimize for size.

gcc -Ofast?

  • Disregard strict standards compliance.
  • enables all -O3 optimizations. It also enables optimizations that are not valid for all standard-compliant programs. It turns on -ffast-math and the Fortran-specific -fno-protect-parens? and -fstack-arrays?.

gcc -Og?

  • Optimize debugging experience.
  • enables optimizations that do not interfere with debugging.

gcc -O3

  • Optimize yet more.
  • turns on all optimizations specified by -O2 and also turns on the -finline-functions?, -funswitch-loops?, -fpredictive-commoning?, -fgcse-after-reload?, -ftree-loop-vectorize?, -ftree-loop-distribute-patterns?, -ftree-slp-vectorize?, -fvect-cost-model?, -ftree-partial-pre? and -fipa-cp-clone? options.

gcc -O2

  • Optimize even more.
  • デバッグを考慮せず最適化オプションを指定
  • GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. As compared to -O, this option increases both compilation time and the performance of the generated code.

gcc -O1?/gcc -O

  • Optimize.
  • デバッグに支障のないものだけが有効化
  • Optimizing compilation takes somewhat more time, and a lot more memory for a large function.

gcc -O0?

  • 何も指定しない場合、これがデフォルト
  • Reduce compilation time and make debugging produce the expected results.

表示

  • gcc -O1 -Q --help=optimize

参考

関連