GCC recommendations and options for fastest code

前端 未结 7 1449
野趣味
野趣味 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 19:10

    gcc -O3 is not guaranteed to be the fastest. -O2 is often a better starting point. After that, profile guided optimization and trying out specific options: http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

    It's a long read, but probably worth it.

    Note that a "Link Time Code Generation" (MSVC) aka "Link Time Optimization" is available in gcc 4.5+

    By the way, there is no specific "fastcall" calling convention for Win64. There is only "the" calling convention: http://msdn.microsoft.com/en-us/magazine/cc300794.aspx

提交回复
热议问题