Skip to main content

IAR Embedded Workbench for Arm 9.70.x

optimize

In this section:
Syntax
#pragma optimize=[goal] [level] [vectorize] [disable]
Parameters

goal

Choose between:

size, optimizes for size

balanced, optimizes balanced between speed and size

speed, optimizes for speed.

no_size_constraints, optimizes for speed, but relaxes the normal restrictions for code size expansion.

level

Specifies the level of optimization—choose between none, low, medium, or high.

vectorize

Enables generation of NEON vector instructions.

disable

Disables one or several optimizations (separated by spaces). Choose from:

no_code_motion, disables code motion

no_cse, disables common subexpression elimination

no_inline, disables function inlining

no_relaxed_fp, disables the language relaxation that optimizes floating-point expressions more aggressively

no_static_to_auto_conversion, disables static-to-auto conversion

no_tbaa, disables type-based alias analysis

no_scheduling, disables instruction scheduling

no_vectorize, disables generation of NEON vector instructions

no_unroll, disables loop unrolling

Table 103. Parameters to #pragma optimize


Description

Use this pragma directive to decrease the optimization level, or to turn off some specific optimizations. This pragma directive only affects the function that follows immediately after the directive.

The parameters size, balanced, speed, and no_size_constraints only have effect on the high optimization level and only one of them can be used as it is not possible to optimize for speed and size at the same time. It is also not possible to use preprocessor macros embedded in this pragma directive. Any such macro will not be expanded by the preprocessor.

Note

If you use the #pragma optimize directive to specify an optimization level that is higher than the optimization level you specify using a compiler option, the pragma directive is ignored.

Example
#pragma optimize=speed
int SmallAndUsedOften()
{
  /* Do something here. */
}

#pragma optimize=size
int BigAndSeldomUsed()
{
  /* Do something here. */
}
See also

Fine-tuning enabled transformations.