You copied the Doc URL to your clipboard.

Optimization options

Control optimization behavior and performance.

Compiler optimization options

Option

Description

-O0

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.

Usage

armflang -O0

-O1

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

Usage

armflang -O1

-O2

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.

Usage

armflang -O2

-O3

Very high optimization. When debugging is enabled, this option typically gives a poor debug view. Arm recommends debugging at lower optimization levels.

Usage

armflang -O3

-Ofast

Enable all the optimizations from level 3, including those performed with the -ffp-mode=fast armflang option.

This level also performs other aggressive optimizations that might violate strict compliance with language standards.

Usage

armflang -Ofast

-ffast-math

Allow aggressive, lossy floating-point optimizations.

Usage

armflang -ffast-math

-ffinite-math-only

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

Usage

armflang -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 (default).

on: Only in the presence of the FP_CONTRACT pragma.

off: Never.

Usage

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

-finline

-fno-inline

Enable or disable inlining (enabled by default).

Usage

armflang -finline

(enable)

armflang -fno-inline

(disable)

-fstack-arrays

-fnostack-arrays

Place all automatic arrays on stack memory.

For programs using very large arrays on particular operating systems, consider extending stack memory runtime limits. Enabled by default at optimization level -Ofast.

Usage

armflang -fstack-arrays

(enable)

armflang -fnostack-arrays

(disable)

-fstrict-aliasing

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.

Usage

armflang -fstrict-aliasing

-funsafe-math-optimizations

-fno-unsafe-math-optimizations

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

Usage

armflang -funsafe-math-optimizations

(enable)

armflang-fno-unsafe-math-optimizations

(disable)

-fvectorize

-fno-vectorize

Enable/disable loop vectorization (enabled by default).

Usage

armflang -fvectorize

(enable)

armflang -fno-vectorize

(disable)

-mcpu=<arg>

Select which CPU architecture to optimize for. Choose from:

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

  • cortex-a72: Optimize for Cortex-A72-based computers.

  • thunderx2t99: Optimize for Cavium ThunderX2-based computers.

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

Usage

armflang -mcpu=<arg>

-march=<arg>

Specifies the name of the target architecture. Choose from:

  • armv8-a: Arm®v8-A architecture.

  • armv8-a+sve: Armv8-A SVE-enabled architecture.

    Note

    When linking to the SVE libary of Arm Performance Libraries, you must also include the -armpl=sve option. For more information, see the Linker options options.

Usage

armflang -march=<arg>

Was this page helpful? Yes No