Setting Optimization Levels

The following table details the effects of the -O0, -O1, -O2, -O3, and -fast options. The table first describes the characteristics shared by both IA-32 and Itanium® architectures and then explicitly describes the specifics (if any) of the -On optionsí behavior on each architecture.

Option Effect
-O0 Disables optimizations.
-O1 Optimizes to favor code size and code locality. Disables loop unrolling. May improve performance for applications with very large code size, any branches, and execution time not dominated by code within loops. In most cases, -O2 is recommended over -O1.
IA-32 systems:
Disables intrinsics inlining to reduce code size.
Itanium-based systems:
Disables software pipelining and global code scheduling.
-O2, -O ON by default. Optimizes for code speed. This is the generally recommended optimization level.
Itanium-based systems:
Enables software pipelining.
-O3 Enables -O2 optimizations and more aggressive optimizations such as loop and memory access transformations. The -O3 optimizations may slow down code in some cases compared to -O2 optimizations. Recommended for applications that have loops that heavily use floating-point calculations and process large data sets.
IA-32 systems:
In conjunction with -ax{K|W|N|B|P} and -x{K|W|N|B|P} options, this option causes the compiler to perform more aggressive data dependency analysis than for -O2. This may result in longer compilation times.
-fast The -fast option enhances execution speed across the entire program by including the following options that can improve run-time performance:
  • -O3 (maximum speed and high-level optimizations.
  • -ipo (enables interprocedural optimizations across files)
  • -static  (prevents linking with shared libraries)
  • -xP (specific optimization for Intel Pentium 4 processor with Streaming SIMD Extensions 3). The -fast option does not include -xP when compiling on Itanium®-based systems.
To override one of the options set by -fast, specify that option after the -fast option on the command line. To target -fast optimizations for a specific processor, use one of the -x options. For example:

prompt>icpc -fast -xW source_file.cpp

The options set by -fast may change from release to release.