Does rustc use NEON floating point operations on ARMv7-A targets?

Rust defines f32 and f64 as IEEE 754-2008 compliant, where NEON instructions on ARMv7-A only comply with 754-1985 (last paragraph on the page). Of particular interest is the lack of support for subnormal numbers. Quoting (denormals is the 1985, renamed to subnormals in 2008):

Additionally, NEON instructions always treats denormals as zero.

I was not able to find information on how clang/LLVM treats this, nor do I have access to IEEE 754, but at least GCC considers this non-compliant:

If the selected floating-point hardware includes the NEON extension (e.g. -mfpu=neon), note that floating-point operations are not generated by GCC’s auto-vectorization pass unless -funsafe-math-optimizations is also specified. This is because NEON hardware does not fully implement the IEEE 754 standard for floating-point arithmetic (in particular denormal values are treated as zero), so the use of NEON instructions may lead to a loss of precision.

My question here, is, how does rustc handle this? Is NEON math used without additional flags?

1 Like

It depends on the target, e.g. Apple targets explicitly enable it with +neon, while Linux targets disable it with -neon. You can check your particular target with rustc --print cfg --target ..., looking for target_feature = "neon", or browse the specs in code here:

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.