float g(float a, float b, float c) {
return a * b + c;
}
#pragma float_control(precise, on)
#pragma STDC FP_CONTRACT OFF
float f(float a, float b, float c) {
return a * b + c;
}
Compile for x86-64 with -mfma -O2 -ffast-math. Expectation is that g may use FMAs but f may not, but in fact both produce FMAs in Clang-14.0.0. Compiler Explorer link with repro: https://godbolt.org/z/TacbzWzxn
It works when there is no -ffast-math on the command line. Presumably the presence of that flag on the command line triggers some global override behavior?
I would love to just remove fast-math from the command line for the relevant TU, but this turns out to be problematic in the build setup for the project I need this in. I was asked to use pragmas for my use case instead, but can't properly because of the above problem.
The text was updated successfully, but these errors were encountered:
Example C code:
Compile for x86-64 with
-mfma -O2 -ffast-math. Expectation is that g may use FMAs but f may not, but in fact both produce FMAs in Clang-14.0.0. Compiler Explorer link with repro: https://godbolt.org/z/TacbzWzxnIt works when there is no
-ffast-mathon the command line. Presumably the presence of that flag on the command line triggers some global override behavior?I would love to just remove fast-math from the command line for the relevant TU, but this turns out to be problematic in the build setup for the project I need this in. I was asked to use pragmas for my use case instead, but can't properly because of the above problem.
The text was updated successfully, but these errors were encountered: