| Typical technobabble from someone who doesn't really understand floating-point. Floating-point is not associative. Reordering operations yields different results, so no compiler will do so, unless you specifically disable standards conformance. The use of SIMD, which is just a type of instruction-level parallelism, has no effect on the result of floating-point operations, unless of course you reorder your operations so that they may be parallelized. What does affect the result of floating-point operations is when rounding happens and at what precision. If we're talking about C, the compiler is allowed to run intermediate operations with higher precision than that mandated by its type. This is merely so that it can use x87 which is 96-bit long by default and only round when it spills to memory and needs to store a 64-bit or 32-bit value. Compilers have flags to disable that behaviour, and it doesn't apply when the SSE unit instead of x87 is used. Using SSE for floating-point doesn't necessarily mean it's using SIMD, most of the instructions have scalar variants. Another example is FMA, which might be substituted for any multiply+add operations. In practice if your code breaks with this it just means it was incorrect in the first place. |
[1]: https://randomascii.wordpress.com/2012/03/21/intermediate-fl...
[2]: https://kristerw.github.io/2021/11/09/fp-contract/
[3]: https://godbolt.org/z/eTz8o6b3P