Search code examples
c++optimization

Does my C++ compiler optimize my code?


While using modern C++ compilers (including MSVC, GCC, ICC), how can I say if it has:

  1. parallelized the code
  2. vectorized the loops (or used other specific processor instructions)
  3. unrolled the loops
  4. detected tail-recursion
  5. performed RVO (return-value optimization)
  6. or optimized in some other way

without diving into the assembler code the compiler produces?


Solution

  • The only way you can really tell is if you examine the assembler output (which you appear to have discounted). Other than that, you could read the doco to see what types of optimization each level of your compiler provides.

    But, in all honesty, if you don't trust that the optimization levels of your compiler are doing the job, you probably won't trust the doco :-)

    I would look at the assembler myself, it's the only way you could be truly certain.