2.1.87. -Onum

This option specifies the level of optimization to be used when compiling source files.

Syntax

-Onum

Where num is one of the following:

0

Minimum optimization. Turns off most optimizations. It gives the best possible debug view and the lowest level of optimization.

1

Restricted optimization. Removes unused inline functions and unused static functions. Turns off optimizations that seriously degrade the debug view. If used with --debug, this option gives a satisfactory debug view with good code density.

2

High optimization. If used with --debug, the debug view might be less satisfactory because the mapping of object code to source code is not always clear.

This is the default optimization level.

3

Maximum optimization. -O3 performs the same optimizations as -O2 however the balance between space and time optimizations in the generated code is more heavily weighted towards space or time compared with -O2. That is:

  • -O3 -Otime aims to produce faster code than -O2 -Otime, at the risk of increasing your image size

  • -O3 -Ospace aims to produce smaller code than -O2 -Ospace, but performance might be degraded.

In addition, -O3 performs extra optimizations that are more aggressive, such as:

  • High-level scalar optimizations, including loop unrolling, for -O3 -Otime. This can give significant performance benefits at a small code size cost, but at the risk of a longer build time.

  • More aggressive inlining and automatic inlining for -O3 -Otime.

  • Multifile compilation by default.

Note

The performance of floating-point code can be influenced by selecting an appropriate numerical model using the --fpmode option.

Note

Do not rely on the implementation details of these optimizations, because they might change in future releases.

Default

If you do not specify -Onum, the compiler assumes -O2.

See also

Copyright © 2007, 2010 ARM Limited. All rights reserved.ARM DUI 0348A
Non-Confidential