Effective optimization strategies on modern C++ compilers

后端 未结 19 2083
梦如初夏
梦如初夏 2020-12-22 17:02

I\'m working on scientific code that is very performance-critical. An initial version of the code has been written and tested, and now, with profiler in hand, it\'s time to

19条回答
  •  太阳男子
    2020-12-22 17:25

    One consequence of C++ being compiled and linked separately is that the compiler is unable to do what would seem to be very simple optimizations, such as move method calls like strlen() out of the termination conditions of loop. Are there any optimization like this one that I should look out for because they can't be done by the compiler and must be done by hand?

    On some compilers this is incorrect. The compiler has perfect knowledge of all code across all translation units (including static libraries) and can optimize the code the same way it would do if it were in a single translation unit. A few ones that support this feature come to my mind:

    • Microsoft Visual C++ compilers
    • Intel C++ Compiler
    • LLVC-GCC
    • GCC (I think, not sure)

提交回复
热议问题