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:
Setting Optimizations describes the behavior of the -On (Linux*) or /On (Windows*) option on each supported architecture.
Restricting Optimizations summarizes options that restrict optimizations.
Diagnostic Options lists options used for troubleshooting.
Additionally, you can refer to the appropriate topics in Compiler Options for more information about any of the options listed here.
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:
|
/O2, /Ox |
-O2, -O |
Optimizes for code speed. This is the default optimization and is the generally recommended optimization level. IA-32 systems:
ItaniumŪ-based systems:
For more information, see the following topic:
|
/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:
ItaniumŪ-based systems:
For more information, see the following topic:
|
/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:
IA-32 and IntelŪ EM64T systems:
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:
For more information on restrictions and usage, see the following topic:
|
The following table lists options that restrict the ability of the IntelŪ Compiler to optimize programs.
Windows |
Linux |
Effect |
---|---|---|
/Od |
-O0 |
Disables optimizations. Linux:
Window:
For more information, see the following topic:
|
/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:
|
/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, |
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.
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:
|