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:
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:
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:
|
/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:
To see what options this option sets, or to get detailed information about the architecture- and operating system-specific behaviors, see the following topic:
|
/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:
ItaniumŪ-based systems:
For more information, see the following topic:
|
/Ox |
No equivalent |
Enables maximum optimization by combining compiler options to perform the following: let the compiler determine which functions to inline, enable global optimizations, specify that EBP be used as a general-purpose register for optimizations, enable all speed optimizations, and enable inline expansion of intrinsic functions. This options is supported on all architectures.
|
/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:
IA-32 and IntelŪ EM64T systems:
|
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:
Windows:
For more information, see the following topic:
|
/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:
|
/Op |
-mp
|
Enables conformance to the ANSI C and IEEE 754 standards for floating-point arithmetic. Restricts optimizations that cause some minor loss or gain of precision in floating-point arithmetic to maintain a declared level of precision and to ensure that floating-point arithmetic more nearly conforms to the ANSI and IEEE* standards. See Improving or Restricting FP Arithmetic Precision for more details. For more information, see the following topic:
|
/Oi- |
-fno-builtin |
Disables inline expansion of intrinsic 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 and Optimization Restriction Support.
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:
|