Specifies the code optimization for applications.
Windows:
General > Optimization (/Od, /O1, /O2, /O3,
/fast)
Optimization > Optimization (/Od, /O1, /O2,
/O3, /fast)
Linux: None
Mac OS X: General > Optimization Level
(-O)
IA-32 architecture, Intel® 64 architecture, IA-64 architecture
Linux and Mac OS X: | -O[n] |
Windows: | /O[n] |
n | Is the optimization level. Possible values are 1, 2, or 3. On Linux and Mac OS X systems, you can also specify 0. |
O2 | Optimizes for code speed. This default may change depending on which other compiler options are specified. For details, see below. |
This option specifies the code optimization for applications.
Option | Description |
---|---|
O (Linux and Mac OS X) | This is the same as specifying O2. |
O0 (Linux and Mac OS X) | Disables all optimizations. On systems using IA-32 architecture and Intel® 64 architecture, this option sets option -fomit-frame-pointer and option -fmath-errno. This option causes certain warn options to be ignored. This is the default if you specify option -debug (with no keyword). |
O1 | Enables optimizations for speed and disables some optimizations that
increase code size and affect speed. To limit code size, this option:
The O1 option sets the following options:
|
O2 | Enables optimizations for speed. This is the generally recommended
optimization level. On systems using IA-64 architecture, this option enables optimizations for speed, including global code scheduling, software pipelining, predication, and speculation. On systems using IA-32 architecture, using -xW or /QxW turns on vectorization at O2 and higher levels. On systems using Intel® 64 architecture, -xW or /QxW is the default and it turns on vectorization. This option also enables:
The O2 option sets the following options:
On Linux and Mac OS X systems, if -g is specified, O2 is turned off and O0 is the default unless O2 (or O1 or O3) is explicitly specified in the command line together with -g. This option sets other options that optimize for code speed. The options set are determined by the compiler depending on which architecture and operating system you are using. |
O3 | Enables O2 optimizations plus more aggressive
optimizations, such as prefetching, scalar replacement, and loop and memory
access transformations. Enables optimizations for maximum speed, such
as:
On Windows systems, the O3 option sets the/Ob2 option. On Linux and Mac OS X systems, the O3 option sets option -fomit-frame-pointer. On systems using IA-32 architecture and Intel® 64 architecture, when
O3 is used with options -ax
or -x (Linux) or with options /Qax
or /Qx (Windows), the compiler performs more aggressive
data dependency analysis than for O2, which may
result in longer compilation times. The O3 optimizations may not cause higher performance
unless loop and memory access transformations take place. The optimizations
may slow down code in some cases compared to O2
optimizations. |
The last O option specified on the command line takes precedence over any others.
The options set by the O option may change from release to release.
O0 | Linux and Mac OS X: None Windows: /Od, /optimize:0, /nooptimize |
O1 | Linux and Mac OS X: None Windows: /optimize:1, /optimize:2 |
O2 | Linux and Mac OS X: None Windows: /Ox, /optimize:3, /optimize:4 |
O3 | Linux and Mac OS X: None Windows: /optimize:5 |
Od compiler option
fast compiler option
Optimizing Applications:
Compiler Optimizations Overview
Optimization Options Summary
Efficient Compilation