Fix ldbl-128ibm nearbyintl use of signaling comparisons on NaNs (bug 18857).
authorJoseph Myers <joseph@codesourcery.com>
Tue, 15 Sep 2015 20:48:05 +0000 (20:48 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Tue, 15 Sep 2015 20:48:05 +0000 (20:48 +0000)
commitdfa0f62011b50cc36107df5fad4130c5368b11e1
tree5d1bd11790c0303dfe0d92a1c970d82ce75eee9c
parent223d1cacc5dafe8af53e84608c2d130721c4edcd
Fix ldbl-128ibm nearbyintl use of signaling comparisons on NaNs (bug 18857).

The ldbl-128ibm implementation of nearbyintl wrongly uses signaling
comparisons such as "if (fabs (u.d[0].d) < TWO52)" on arguments that
might be NaNs, when "invalid" exceptions should not be raised.  (For
hard float, this issue may be hidden by
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58684>, powerpc GCC
wrongly only using unordered comparison instructions.)  This patch
fixes this by just returning the argument if it is not finite (because
of the arbitrary value of the low part of a NaN in IBM long double,
there are quite a lot of comparisons that could end up involving a NaN
when the argument to nearbyintl is a NaN, so excluding NaN arguments
at the start is the simplest and safest fix).

Tested for powerpc-nofpu, where it removes failures for spurious
"invalid" exceptions from nearbyintl.

[BZ #18857]
* sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c (__nearbyintl): Just
return non-finite argument without doing ordered comparisons on
it.
ChangeLog
NEWS
sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c