Optimization Options Summary

This topic discusses the command-line options that affect the following optimizations: code size and locality and code speed. To specify one of these optimizations, take into consideration the nature and structure of your application as indicated in the more detailed description of the options (below).

Windows*

Linux*

Description

/O1

-O1

Affects code size and locality.

/O2

-O2 (or -O)

Affects code speed; this is the default option.

/O3

-O3

Enables aggressive optimization for code speed.

/fast

-fast

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

/Od

-O0

Disables optimization.

These options behave similarly on IA-32, IntelŪ EM64T, IntelŪ ItaniumŪ architectures.

The following sections summarize the most common optimizations:

Additionally, you can refer to the appropriate topics in Compiler Options for more information about any of the options listed here.

Setting Optimizations

The following table details the effects of common optimization options. The table lists the relevant options, describes the characteristics shared by IA-32, ItaniumŪ, and IntelŪ EM64T architectures, and explicitly describes the specific behavior summarizes the -On (Linux) or /On (Windows) option switches.

Windows

Linux

Effect

/O1

-O1

Optimizes to favor code size and code locality. Disables loop unrolling. Disables intrinsics inlining to reduce code size. Enables optimizations for speed. Also disables intrinsic recognition and the -fp (Linux) or /Oy- (Windows) option.

May improve performance for applications with very large code size, many branches, and execution time not dominated by code within loops.

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

This option behaves differently depending on architecture and operating system. 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, /Ox

-O2, -O

Optimizes for code speed. This is the default optimization and is the generally recommended optimization level.

IA-32 systems:

  • Linux: This option is the same as the -O1 (Linux) or /O1 (Windows) option.

ItaniumŪ-based systems:

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

  • On these systems, the -O2 (Linux) or /O2 (Windows) option enables inlining of intrinsics. It also enables 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 and optimizations, and dead store elimination.

For more information, see the following topic:

  • -O2 compiler option

/O3

-O3

Enables -O2 (Linux) or /O2 (Windows) optimizations and in addition, enables more aggressive optimizations such as prefetching, scalar replacement, 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.

IA-32 systems:

  • Causes the compiler to perform more aggressive data dependency analysis than for -O2 (Linux) or /O2 (Windows), which might result in longer compilation times, when used with the -ax or -x (Linux) or /Qax or /Qx (Windows)

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

This option is a single, simple method 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

Additionally for IA-32 and IntelŪ EM64T systems, the -xP (Linux) or /QxP (Windows) option that is set by the fast option cannot be overridden by other command line options. If you specify this option and 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. In such cases, use this option along with processor-specific options. For example, if you want to use the processor-specific option -xW (Linux) or /QxW (Windows), do not specify the fast option; instead, specify the following combination of options:

  • Linux systems: -O3 -ipo -no-prec-div -static -xW

  • Windows systems: /O3 /Qipo /Qprec-div- /QxW

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 optimizations.

Linux:

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

Window:

  • Use /Od to specify 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

Specifying the option turns off the default -O2 (Linux) or /O2 (Windows) option and makes -O0 (Linux) or /Od (Windows) the default unless -O2 (Linux) or /O2 (Windows), or -O1 or -O3 (Linux) or /O1 or /O3 (Windows), is explicitly specified in the command line together with this option.

For more information, see the following topic:

  • -g compiler option

/fltconsistency

-fltconsistency

Enables improved floating-point consistency and may slightly reduce execution speed. It limits floating-point optimizations and maintains declared precision. It also disables inlining of math library functions.

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.

For more information, see the following topic:

  • -sox compiler option