Skip to main content

IAR Embedded Workbench for Arm 9.70.x

Optimization levels

In this section:

The compiler supports different levels of optimizations. This table lists optimizations that are typically performed on each level:

Optimization level

Description

None (Best debug support)

Variables live through their entire scope

Dead code elimination

Redundant label elimination

Redundant branch elimination

Low

Same as above but variables only live for as long as they are needed, not necessarily through their entire scope

Medium

Same as above, and:

Live-dead analysis and optimization

Dead code elimination

Redundant label elimination

Redundant branch elimination

Code hoisting

Peephole optimization

Some register content analysis and optimization

Common subexpression elimination

Code motion

Static clustering

High (Balanced)

Same as above, and:

Instruction scheduling

Cross jumping

Advanced register content analysis and optimization

Loop unrolling

Function inlining

Type-based alias analysis

Table 91. Compiler optimization levels 


Note

Some of the performed optimizations can be individually enabled or disabled. For more information, see Fine-tuning enabled transformations.

A high level of optimization might result in increased compile time, and will also most likely make debugging more difficult, because it is less clear how the generated code relates to the source code. For example, at the low, medium, and high optimization levels, variables do not live through their entire scope, which means processor registers used for storing variables can be reused immediately after they were last used. Due to this, the C-SPY Watch window might not be able to display the value of the variable throughout its scope, or even occasionally display an incorrect value. At any time, if you experience difficulties when debugging your code, try lowering the optimization level.