Optimization Options Summary

This topic discusses the compiler options affecting code size, locality and code speed. The following table summarizes the most common code optimization options you can use for quick results.

Windows*

Linux*

Description

/O3

-O3

Enables aggressive optimization for code speed. Recommended for code with loops that perform calculations or process large data sets.

/O2

-O2 (or -O)

Affects code speed. This is the default option, so the compiler uses this optimization level if you do not specify anything.

/O1

-O1

Affects code size and locality. Disables specific optimizations.

/fast

-fast

Enables a collection of common, recommended optimizations for run-time performance.

/Od

-O0

Disables optimization. Use this for debugging and rapid compilation.

The following sections summarize the common optimizations:

Setting Optimization Levels

The following table lists the relevant code optimization options, describes the characteristics shared by IA-32, Itanium®, and IntelŪ EM64T architectures, and describes the general behavior on each architecture.

The architectural differences and compiler options these code optimizations either enable or disable are also listed in more detail in the associated Compiler Options topics; each option discussion includes a link to the appropriate Compiler Options topic.

Windows

Linux

Effect

/O1

-O1

Optimizes to favor code size and code locality. This optimization level might improve performance for applications with very large code size, many branches, and execution time not dominated by code within loops. In general, this optimization level does the following:

  • Enables global optimization.

  • Disables intrinsic recognition and intrinsics inlining.

  • On ItaniumŪ-based systems, it disables software pipelining, loop unrolling, and global code scheduling.

In most cases, -O2 (Linux) or /O2 (Windows) is recommended over this option.

To see which options this option sets or to get detailed information about the architecture- and operating system-specific behaviors, see the following topic:

  • -O1 compiler option

/O2

-O2, -O

Optimizes for code speed. Since this is the default optimization, if you do not specify an optimization level the compiler will use this code optimization level automatically. This is the generally recommended optimization level; however, specifying other compiler options can affect the optimization normally gained using this level.

This option enables intrinsics inlining and the following capabilities for performance gain: constant propagation, copy propagation, dead-code elimination, global register allocation, global instruction scheduling and control speculation, loop unrolling, optimized code selection, partial redundancy elimination, strength reduction/induction variable simplification, variable renaming, exception handling optimizations, tail recursions, peephole optimizations, structure assignment lowering optimizations, and dead store elimination.

This option behaves differently depending on architecture.

Itanium®-based systems:

  • Enables optimizations for speed, including global code scheduling, software pipelining, predication, speculation, and data prefetch.

To see what options this option sets, or to get detailed information about the architecture- and operating system-specific behaviors, see the following topic:

  • -O2 compiler option

/O3

-O3

Enables -O2 (Linux) or /O2 (Windows) optimizations, and enables more aggressive optimizations such as prefetching, scalar replacement, cache blocking, and loop and memory access transformations. Enables optimizations for maximum speed, but does not guarantee higher performance unless loop and memory access transformation take place. The optimizations enabled by this option can slow down code in some cases compared to -O2 (Linux) or /O2 (Windows) optimizations.

Recommended for applications that have loops that heavily use floating-point calculations and process large data sets.

Like the other code optimization options, this option behaves differently depending on architecture and operating system.

IA-32 systems:

  • When used with the -ax or -x (Linux) or /Qax or /Qx (Windows), this option causes the compiler to perform more aggressive data dependency analysis than for -O2 (Linux) or /O2 (Windows); however, this scenario might result in longer compilation times.

  • -xP and -axP are the only valid values on Mac OS* systems.

ItaniumŪ-based systems:

  • Enables optimizations for technical computing applications (loop-intensive code): loop optimizations and data prefetch.

For more information, see the following topic:

  • -O3 compiler option

/fast

-fast

Provides a simple, single optimization that allows you to enable a collection of optimizations for run-time performance. This option sets specific options, depending on architecture and operating system:

ItaniumŪ-based systems:

  • Linux: -ipo, -O3, and -static

  • Windows: /O3 and /Qipo

IA-32 and IntelŪ EM64T systems:

  • Linux: -ipo, -O3, -no-prec-div, -static, and -xP

  • Windows: /O3, /Qipo, /Qprec-div-, and /QxP

Note

Mac OS*: The -xP and -static options are not supported.

Programs compiled with the -xP (Linux) or /QxP (Windows) option will detect non-compatible processors and generate an error message during execution.

Additionally, for IA-32 and IntelŪ EM64T systems, the -xP (Linux) or /QxP (Windows) option that is set by this option cannot be overridden by other command line options. If you specify this option along with a different processor-specific option, such as -xN (Linux) or /QxN (Windows), the compiler will issue a warning stating the -xP or /QxP option cannot be overridden; the best strategy for dealing with this restriction is to explicitly specify the options you want to set from the command line.

While this option enables other options quickly, the specific options enabled by this option might change from one compiler release to the next. Be aware of this possible behavior change in the case where you use makefiles.

For more information on restrictions and usage, see the following topic:

Restricting Optimization

The following table lists options that restrict the ability of the Intel® compiler to optimize programs.

Windows

Linux

Effect

/Od

-O0

Disables all optimizations. Use this during development stages where fast compile times are desired.

Linux:

  • Sets option -fp and option -fmath-errno.

Windows:

  • Use /Od to disable all optimizations while specifying particular optimizations, such as: /Od /Ob1 (disables all optimizations, but only enables inlining)

For more information, see the following topic:

  • -O0 compiler option

/Zi, /Z7

-g

Generates symbolic debugging information in object files for use by debuggers.

This option enables or disables other compiler options depending on architecture and operating system; for more information about the behavior, see the following topic:

  • -g compiler option

/fltconsistency

-fltconsistency

Enables improved floating-point consistency, but it might slightly reduce execution speed. The option limits floating-point optimizations and maintains declared precision.

For more information, see the following topic:

No equivalent

-fmath-errno,
-fno-math-errno

Instructs the compiler to assume that the program tests errno after calls to math library functions.

For more information on ways to restrict optimization, see Using Qoption Specifiers.

Diagnostic Options

Windows

Linux

Effect

/Qsox

-sox

Instructs the compiler to save the compiler options and version number in the executable. During the linking process, the linker places information strings into the resulting executable. Slightly increases file size, but using this option can make identifying versions for regression issues much easier.

For more information, see the following topic:

  • -sox compiler option