LLVM's Flang Compiler Adds -Ofast & -ffast-math Support
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.
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.
1 Comment