I was fiddling in Compiler Explorer, and I found that the order of arguments passed to std::min changes the emitted assembly.
Here\'s the example on Godbolt Compiler Expl
Consider: std::signbit(std::min(+0.0, -0.0)) == false && std::signbit(std::min(-0.0, +0.0)) == true
.
The only other difference is if both arguments are (possibly different) NaNs, the second argument should be returned.
You can allow gcc to reorder the arguments by using the -funsafe-math-optimizations -fno-math-errno
optimsations (Both enabled by -ffast-math
). unsafe-math-optimizations
allows the compiler to not care about signed zero, and finite-math-only
to not care about NaNs