You copied the Doc URL to your clipboard.

Optimization options

Optimization options

Options that control optimization behavior and performance.

Compiler optimization options





Minimum optimization for the performance of the compiled binary.

Turns off most optimizations. When debugging is enabled, this option generates code that directly corresponds to the source code. Therefore, this might result in a significantly larger image.

This is the default optimization level.

armclang -O0


Restricted optimization.

When debugging is enabled, this option gives the best debug view for the trade-off between image size, performance, and debug.

armclang -O1


High optimization.

When debugging is enabled, the debug view might be less satisfactory because the mapping of object code to source code is not always clear.

The compiler might perform optimizations that cannot be described by debug information.

armclang -O2


Very high optimization.

When debugging is enabled, this option typically gives a poor debug view.

Arm recommends debugging at lower optimization levels.

armclang -O3


Enables all the optimizations from level 3 including those performed with the -ffp-mode=fast armclang option. This level also performs other aggressive optimizations that might violate strict compliance with language standards.

armclang -Ofast


Allow aggressive, lossy floating-point optimizations.

armclang -ffast-math


Enable optimizations that ignore the possibility of NaN and +/-Inf.

armclang -ffinite-math-only

-ffp-contract={fast | on | off}

Controls when the compiler is permitted to form fused floating-point operations (such as FMAs).

fast: Always, except when using -O0 to set the optimization level to 0.

on: Only in the presence of the FP_CONTRACT pragma (default).

Off: Never.

armclang -ffp-contract={fast on | off}



Enable/disable inlining (enabled by default).

armclang -finline (enable)

armclang -fno-inline (disable)


Tells the compiler to adhere to the aliasing rules defined in the source language.

In some circumstances, this flag allows the compiler to assume that pointers to different types do not alias. Enabled by default when using -Ofast.

armclang -fstrict-aliasing



This option enables reassociation and reciprocal math optimizations, and does not honor trapping nor signed zero.

armclang -funsafe-math-optimizations (enable)

armclang -fno-unsafe-math-optimizations (disable)



Enable/disable loop vectorization (enabled when using -O2 to set the optimization level to 2).

armclang -fvectorize (enable)

armclang -fno-vectorize (disable)


Select which CPU architecture to optimize for -mcpu=native causes the compiler to auto-detect the CPU architecture from the build computer.

armclang -mcpu=<arg>

Was this page helpful? Yes No