This topic lists the most common code optimization options, describes the characteristics shared by IA-32, Intel® 64, and IA-64 architectures, and describes the general behavior for each architecture.
The architectural differences and compiler options enabled or disabled by these options are also listed in more specific detail in the associated Compiler Options topics; therefore, each option discussion listed below includes a link to the appropriate reference topic.
Linux* and Mac OS* X |
Windows* |
Description |
---|---|---|
Optimizes to favor smaller code size and code locality. In most cases, -O2 (Linux* OS and Mac OS* X) or /O2 (Windows* OS) is recommended over this option. This optimization disables some optimizations that normally increase code size. This 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:
IA-64 architecture:
|
||
Optimizes for code speed. Since this is the default optimization, if you do not specify an optimization level the compiler will use this optimization level automatically. This is the generally recommended optimization level; however, specifying other compiler options can affect the optimization normally gained using this level. In general, the resulting code size will be larger than the code size generated using -O1 (Linux and Mac OS X) or /O1 (Windows). This option enables the following capabilities for performance gain: inlining intrinsic functions, 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. For IA-32 and Intel 64 architectures:
IA-64 architecture:
|
||
Enables -O2 (Linux and Mac OS X) or /O2 (Windows) optimizations, as well as more aggressive optimizations, including prefetching, scalar replacement, cache blocking, and loop and memory access transformations. As compared to -O2 (Linux) or /O2 (Windows), the optimizations enabled by this option often result in faster program execution, but can slow down code execution in some cases. Using this option may result in longer compilation times. This option is recommended for loop-intensive applications that perform substantial floating-point calculations or process large data sets. |
||
Provides a single, simple optimization that enables a collection of optimizations that favor run-time performance. This is a good, general option for increasing performance in many programs. For IA-32 and Intel 64 architectures, the -xSSSE3 (Linux and Mac OS X) or /QxSSSE3 (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 -xSSE2 (Linux) or /QxSSE2 (Windows), the compiler will issue a warning stating the -xSSSE3 or /QxSSSE3 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.
|
The following syntax examples demonstrate using the default option to compile an application:
Operating System |
Example |
---|---|
Linux and Mac OS X |
icpc -O2 prog.cpp |
Windows |
icl /O2 prog.cpp |
Refer to Quick Reference Lists for a complete listing of the quick reference topics.