You copied the Doc URL to your clipboard.

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


Enable 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


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

fast: Always (default).

on: Only in the presence of the FP_CONTRACT pragma.

off: Never.


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



Enable or disable inlining (enabled by default).


armclang -finline


armclang -fno-inline




Enable (-fsimdmath) or disable (-fno-simdmath) the vectorized libm library (libamath) to help the vectorization of loops containing calls to libm.

For more information, see

Default is -fno-simdmath.


armclang -fsimdmath

armclang -fno-simdmath


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/disable loop vectorization (enabled by default).


armclang -fvectorize


armclang -fno-vectorize



Select which CPU architecture to optimize for. Choose from:

  • native: Auto-detect the CPU architecture from the build computer.

  • neoverse-n1: Optimize for Neoverse N1-based computers.

  • thunderx2t99: Optimize for Cavium ThunderX2-based computers.

  • generic: Generates portable output suitable for any Armv8-A computer.


armclang -mcpu=<arg>


Specifies the base architecture and extensions available on the target.

-march=<arg> where <arg> is constructed as name[+[no]feature+...]:


armv8-a: Arm®v8-A application architecture profile.

armv8.1-a: Armv8.1 application architecture profile.

armv8.2-a: Armv8.2 application architecture profile.


Is the name of an optional architectural feature that can be explicitly enabled with +feature and disabled with +nofeature.

For AArch64, the following features can be specified:

  • crc - Enable CRC extension. On by default for -march=armv8.1-a or higher.

  • crypto - Enable Cryptographic extension.

  • fullfp16 - Enable FP16 extension.

  • lse - Enable Large System Extension instructions. On by default for -march=armv8.1-a or higher.

  • sve - Scalable Vector Extension (SVE). This feature also enables fullfp16. See Scalable Vector Extension for more information.

  • sve2- Scalable Vector Extension version two (SVE2). This feature also enables sve. See Arm A64 Instruction Set Architecture for SVE and SVE2 instructions.

  • sve2-aes - SVE2 Cryptographic extension. This feature also enables sve2.

  • sve2-bitperm - SVE2 Cryptographic Extension. This feature also enables sve2.

  • sve2-sha3 - SVE2 Cryptographic Extension. This feature also enables sve2.

  • sve2-sm4 - SVE2 Cryptographic Extension. This feature also enables sve2.


When enabling either the sve2 or sve features, to link to the SVE-enabled version of Arm Performance Libraries, you must also include the -armpl=sve option. For more information about the supported options for -armpl, see the -armpl description.


armclang -march=<arg>


armclang -march=armv8-a

armclang -march=armv8-a+sve

armclang -march=armv8-a+sve2

Was this page helpful? Yes No