soft-fp64: __fsat64 incorrectly returns NaN for a NaN input. It should return zero.
I noticed a couple things while inspecting the soft fp64 code.
-
I thinkAfter remembering that__feq64
does not handle a = -0, b = +0 correctly. I believe it will incorrectly return false. It seems like it either needs an extraa.y == 0x80000000
orb.y == 0
in the last clause.a.y
is the most significant 32-bits, I was able to convince myself that this code was correct. -
I think the__flt64_nonnan
could be simplified a lot. Using 64-bit integer math, I think it could be:
// is_zero returns true for ±0, return false when (a == 0 && b == 0).
return (!is_zero(__a) || !is_zero(__b)) && __a < __b;
IEEE floating point numbers are specifically designed to allow using integer comparisons in this manner. See also wikipedia.
-
__fsat64
incorrectly returns NaN for a NaN input. It should return zero.