Fix powerpc fmax, fmin sNaN handling (bug 20947).
commit9ce4ac64b234c976ae56061afd5774896c5513c9
authorJoseph Myers <joseph@codesourcery.com>
Thu, 15 Dec 2016 00:43:16 +0000 (15 00:43 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Thu, 15 Dec 2016 00:43:16 +0000 (15 00:43 +0000)
tree2d0aae52da78653fcebf4df843e5efc40c8aecd2
parentf02bb0004c5b1944333fd8e74ac1efda3074084b
Fix powerpc fmax, fmin sNaN handling (bug 20947).

Various fmax and fmin function implementations mishandle sNaN
arguments:

(a) When both arguments are NaNs, the return value should be a qNaN,
but sometimes it is an sNaN if at least one argument is an sNaN.

(b) Under TS 18661-1 semantics, if either argument is an sNaN then the
result should be a qNaN (whereas if one argument is a qNaN and the
other is not a NaN, the result should be the non-NaN argument).
Various implementations treat sNaNs like qNaNs here.

This patch fixes the powerpc versions of these functions (shared by
float and double, 32-bit and 64-bit).  The structure of those versions
is that all ordered cases are already handled before anything dealing
with the case where the arguments are unordered; thus, this patch
causes no change to the code executed in the common case (neither
argument a NaN).

Tested for powerpc (32-bit and 64-bit), together with tests to be
added along with the x86_64 / x86 fixes.

[BZ #20947]
* sysdeps/powerpc/fpu/s_fmax.S (__fmax): Add the arguments when
either is a signaling NaN.
* sysdeps/powerpc/fpu/s_fmin.S (__fmin): Likewise.
ChangeLog
sysdeps/powerpc/fpu/s_fmax.S
sysdeps/powerpc/fpu/s_fmin.S