RFC: Deprecate -Ofast

This is one of the interpretations, but not the only one.

In HPC, people really care about precision and that’s why “fast math” became a list of different deviations from the standards (IEEE/ISO) that are “known to not violate the expectations of the underlying maths (or do so in a precise way)”.

IEEE talks about digital precision. For example, mul + add may not have the same binary answer as mla, so IEEE assumes precision is lost. But it’s often gained.

ISO C/C++ have to assume the program is the source of truth. Compilers are not allowed to change the semantics of what the programmer wrote, but in reality, problems have to be translated to programs, and often the original (maths) semantics is lost, just like when we convert from C++ to IR, to asm. Here, “fast math” can mean: “I don’t care about C++ FP semantics, but I do care about the original equation”.

In the end, -ffast-math is usually only equals to “don’t care” in non-scientific code, but it’s still very useful in scientific code, due to its often precise semantics of what to bypass/ignore.

3 Likes