GCC recommendations and options for fastest code

前端 未结 7 1481
野趣味
野趣味 2020-12-23 18:34

I\'m distributing a C++ program with a makefile for the Unix version, and I\'m wondering what compiler options I should use to get the fastest possible code (it falls into t

7条回答
  •  伪装坚强ぢ
    2020-12-23 18:52

    Consider using -fomit-frame-pointer unless you need to debug with gdb (yuck). That will give the compiler one more register to use for variables (otherwise this register is wasted for useless frame pointers).

    Also you may use something like -march=core2 or more generally -march=native to enable the compiler to use newer instructions and further tune the code for the specified architecture, but for this you must be sure your code will not be expected to run on older processors.

提交回复
热议问题