Skip to main content

IAR Embedded Workbench for RL78 5.20

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

Code hoisting

Peephole optimization

Register content analysis and optimization

Common subexpression elimination

Static clustering

High (Balanced)

Same as above, and:

Cross jumping

Instruction scheduling (when optimizing for speed or balanced)

Cross call (when optimizing for size or balanced)

Loop unrolling

Function inlining

Code motion

Type-based alias analysis

Table 70. 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.