Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

O

Specifies the code optimization for applications.

Syntax

Linux:

-O[n]

macOS:

-O[n]

Windows:

/O[n]

Arguments

n

Is the optimization level. Possible values are 1, 2, or 3. On Linux* and macOS systems, you can also specify 0.

Default

O2

Optimizes for code speed. This default may change depending on which other compiler options are specified. For details, see below.

Description

This option specifies the code optimization for applications.

Option

Description

O (Linux* and macOS)

This is the same as specifying O2.

O0 (Linux and macOS)

Disables all optimizations.

This option may set other options. This is determined by the compiler, depending on which operating system and architecture you are using. The options that are set may change from release to release.

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:

  • Enables global optimization; this includes data-flow analysis, code motion, strength reduction and test replacement, split-lifetime analysis, and instruction scheduling.

This option may set other options. This is determined by the compiler, depending on which operating system and architecture you are using. The options that are set may change from release to release.

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

O2

Enables optimizations for speed. This is the generally recommended optimization level.
Vectorization is enabled at O2 and higher levels.

On ifort systems using IA-32 architecture: Some basic loop optimizations such as Distribution, Predicate Opt, Interchange, multi-versioning, and scalar replacements are performed.

This option also enables:

  • Inlining of intrinsics

  • Intra-file interprocedural optimization, which includes:

    • inlining

    • constant propagation

    • forward substitution

    • routine attribute propagation

    • variable address-taken analysis

    • dead static function elimination

    • removal of unreferenced variables

  • 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

    • dead store elimination

This option may set other options, especially options that optimize for code speed. This is determined by the compiler, depending on which operating system and architecture you are using. The options that are set may change from release to release.

On Windows* systems, this option is the same as the Ox option.

On Linux* and macOS 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.

On Linux systems, the -debug inline-debug-info option will be enabled by default if you compile with optimizations (option -O2 or higher) and debugging is enabled (option -g).

Many routines in the shared libraries are more highly optimized for Intel® microprocessors than for non-Intel microprocessors.

O3

Performs O2 optimizations and enables more aggressive loop transformations such as Fusion, Block-Unroll-and-Jam, and collapsing IF statements.

This option may set other options. This is determined by the compiler, depending on which operating system and architecture you are using. The options that are set may change from release to release.

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 O3 option is recommended for applications that have loops that heavily use floating-point calculations and process large data sets.

Many routines in the shared libraries are more highly optimized for Intel® microprocessors than for non-Intel microprocessors.

The last O option specified on the command line takes precedence over any others.

IDE Equivalent

Visual Studio: General > Optimization (/Od, /O1, /O2, /O3, /fast)

Optimization > Optimization (/Od, /O1, /O2, /O3, /fast)

Alternate Options

O2

Linux and macOS: None
Windows: /Ox

See Also