Why FMAs are generated by clang unlike gcc?

I have a testcase for which clang generates FMAs and gcc, icc doesn’t; even when -ffast-math flag is passed Test case link. Are compilers allowed to generate different instructions for different intrinsics? How do I avoid generating FMAs in such cases?

Your example is using -ffast-math, so anything goes. FMA is allowed or not. gcc and clang probably have different opinions on whether fma is faster for znver3

1 Like

You can use -ffp-contract=off to disable fma.