4 ms·
Don't CPU compilers in general, not just ARM ones, avoid using FMA for normal arithmetic unless you use -ffast-math? I don't think FMAs are inaccurate per se, b
by TazeTSchnitzel 5y ago
Don't CPU compilers in general, not just ARM ones, avoid using FMA for normal arithmetic unless you use -ffast-math? I don't think FMAs are inaccurate per se, but they will produce differently-rounded results than multiplications and additions, and moreover you have to do a bunch of reassociation to make good use of them. C and C++ expect precise math by default.
GLSL and the like are different.
- PennRobotics 5y agoI think for this particular instruction, -ffp-contract=fast
- qayxc 5y ago> Don't CPU compilers in general, not just ARM ones, avoid using FMA for normal arithmetic unless you use -ffast-math? Doesn't seem o be the case: MSVC avoids FMA, while GCC prefers it: https://godbolt.org/z/e9EcfjdeY https://godbolt.org/z/e9EcfjdeY
- celrod 5y agohttps://godbolt.org/z/v67Tc3jEc https://godbolt.org/z/v67Tc3jEc gcc and icc will use fma under `-O3`, but Clang won't.
- thxg 5y agogcc will avoid FMA if you specify `-std=c17` (or another C standard, instead of the default "GNU" variant). Note that it has to avoid FMA in that case because fusing (a * b) + c would not comply with the C17/IEEE-754 spec (see -fexcess-precision in the manual).