Setting Optimization Level

Option

Description

-O, -O1, -O2

Optimize for speed, but disable some optimizations that increase code size for a small speed benefit. Default.
Note: The mostly used option is -O2, -O, -O1 are used for compatibility.

-O3
 

Enables -O2 option with more aggressive optimization and sets high-level optimizations, including loop transformation, OpenMP, and prefetching. High-level optimizations use the properties of source code constructs such as loops and arrays in applications written in high-level programming languages.

Optimizes for maximum speed, but may not improve performance for some programs.

-O0

Disables optimizations -O1 and-or -O2.