LLVM's Flang Compiler Adds -Ofast & -ffast-math Support

Written by Michael Larabel in LLVM on 14 December 2022 at 01:00 PM EST. 1 Comment
Flang as LLVM's Fortran language front-end has landed support for the -Ofast and -ffast-math compiler flags.

As with Clang and other compilers, the -Ofast optimization level can be used if wanting to aggressively optimize the code generation beyond the -O3 level but disregarding strict standards compliance. Generally speaking -Ofast can be beneficial if wanting to maximize performance but needing to take care to ensure no unsafe math or other problems arising from the generated binary.

As part of enabling -Ofast for Flang, the patch also enables the -ffast-math flag too. The "fast math" flag disregards IEEE compliance, disables some checks around values, and other changes in the name of trying to yield faster floating-point math operations. Making use of Flang's -ffast-math flips on -fno-honor-infinities, -fno-honor-nans, -fassociative-math, -freciprocal-math, -fapprox-func, -fno-signed-zeros, and -ffp-contract=fast.

Flang's -Ofast currently equates to -O3 and -ffast-math while the plan is also to implement -fstack-arrays in there too in the future.

The Flang -Ofast and -ffast-math support was merged last week for the LLVM 16.0 release happening in the early months of 2023.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week