Search code examples
c++xcodeoptimizationclangloop-unrolling

Why is loop unrolling off by default in XCode?


It seems the Unroll Loops optimization settings under the Apple LLVM 8.0 - Code Generation section is turned off by default in the latest XCode, 8.2.1, even for the Release configuration. Any good reason for that? I thought loop unrolling was one of the most basic optimizations.


Solution

  • It seems it is disabled to avoid increasing the size of the generated code.

    Tuning for Performance and Responsiveness

    Table 6-1 Compiler optimization options

    Faster

    The compiler performs nearly all supported optimizations that do not require a space-time tradeoff. The compiler does not perform loop unrolling or function inlining with this option. This option increases both compilation time and the performance of generated code.

    Fastest

    The compiler performs all optimizations in an attempt to improve the speed of the generated code. This option can increase the size of generated code as the compiler performs aggressive inlining of functions. This option is generally not recommended.