-O (-Os, -Ot): Main Optimization Target

Group

OPTIMIZATIONS

Scope

Function

Syntax
  -O(s|t)
  
  
Arguments

s: Optimize for code size (default)

t: Optimize for execution speed

Default
  -Os
  
  
Defines

__OPTIMIZE_FOR_SIZE__

__OPTIMIZE_FOR_TIME__

Pragmas

None

Description

There are vario us points where the Compiler has to choose between two possibilities: it can either generate fast, but large code, or small but slower code.

The Compiler generally optimizes on code size. It often has to decide between a runtime routine or an expanded code. The programmer can decide whether to choose between the slower and shorter or the faster and longer code sequence by setting a command line switch.

The -Os option directs the Compiler to optimize the code for smaller code size. The Compiler trades faster-larger code for slower-smaller code.

The -Ot option directs the Compiler to optimize the code for faster execution time. The Compiler replaces slower/smaller code with faster/larger code.

Note: This option only affects some special code sequences. This option has to be set together with other optimization options (e.g., register optimization) to get best results.
Example
  -Os