Rate This Document
Findability
Accuracy
Completeness
Readability

-fsimdmath,-msimdmath-64

Description

-fsimdmath enables the mathlib vector math library. After this option is enabled, the compiler automatically searches for code segments that can use the vector math library in the vectorization phase and generates vectorized code that contains vectorized math functions when performance benefits are confirmed. This option applies to the frontend of the C, C++, and Fortran languages.

-msimdmath-64 enables the generation of the 64-bit vectorized math function. This option is disabled by default. Currently, mathlib does not provide the implementation of the 64-bit vectorized math function. Therefore, if this option is directly enabled, a link error may occur. This option is set to directly enable the 128-bit math library provided by mathlib without reducing the original open-source functions. If you need to use a 64-bit vector math library, you can find the implementation and specify the related math library.

Usage

  • To enable all vector math library APIs provided by mathlib, add -fsimdmath -O3 or -fsimdmath -ftree-vectorize to the command line. -O3 and -ftree-vectorize are used to enable vectorization optimization pass, which is the prerequisite for the vector math library to take effect.
  • The compiler provides the simdmath.h header file in the gcc-12.3.1-2025.12-aarch64-linux/lib64/gcc/aarch64-linux-gnu/12.3.1/include directory and the simdmath_f.h header file in the gcc-12.3.1-2025.12-aarch64-linux/lib64/gcc/aarch64-linux-gnu/12.3.1/finclude directory. The two header files are the simd declarations in C/C++ and Fortran, including all the 11 vector math library functions supported by mathlib. If you want to enable only some vector functions, delete the corresponding function declaration from the header file.

    Option: -lmathlib -fsimdmath -lm

  • Enabling the vector math library does not mean that all math functions are implemented in vector mode. In some scenarios, vector functions cannot be called. As a result, vector functions and scalar functions may be called at the same time.