Skip to content

Compiler optimizations

Felipe Torrezan edited this page Apr 3, 2024 · 2 revisions

In the Optimizations tab you can easily choose the optimization level from None up to High.

  • Open the project’s options with ProjectOptions (ALT+F7).
  • Navigate to the C/C++ Compiler category → Optimizations tab.

When High is selected, it is possible to select among 3 different optimization objectives:

  • Size means the smallest code size. This objective can be selected when minimizing the program memory consumption is more important than execution speed.

  • Balanced will use heuristics for making decisions on the transformations used for each piece of code. This objective can be selected to make the code run as fast as possible, whenever it doesn’t mean a toll in terms of code size.

  • Speed means code that executes faster. This objective can be selected when speed is more important than the code size.

project-options-compiler-optimizations

When the High/Speed level is selected, the check box No size constraints can be enabled. This option will generate code that executes as fast as possible.

project-options-compiler-no-constraints

The Enabled Transformations can be cherry-picked when higher optimization levels are selected. When enabled, these transformations significantly affect the code generation for the better.

Tip

When debugging code, it is recommended to leave the compiler optimization level on None or Low, where those transformations do not happen, so the generated code will have a better correlation with the source code. A lower optimization level provides better visibility for debugging purposes. The "Debug" configuration uses the Low level as default.

Tip

When the application is ready to be released, with its source code already debugged, the compiler optimization level can be raised to High as in the "Release" build configuration. The Workspace window offers a build configuration drop-down box which allows to quickly switch back and forth amongst the project’s build configurations:

workspace-build-configuration-switcher