From ad39cce0da0161dba69781c53349acf2e23f156c Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 23 Jun 2015 22:24:20 +0000 Subject: Fix sin, sincos missing underflows (bug 16526, bug 16538). Similar to various other bugs in this area, some sin and sincos implementations do not raise the underflow exception for subnormal arguments, when the result is tiny and inexact. This patch forces the exception in a similar way to previous fixes. Tested for x86_64, x86, mips64 and powerpc. [BZ #16526] [BZ #16538] * sysdeps/ieee754/dbl-64/s_sin.c: Include . (__sin): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/flt-32/k_sinf.c: Include . (__kernel_sinf): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128/k_sincosl.c: Include . (__kernel_sincosl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128/k_sinl.c: Include . (__kernel_sinl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128ibm/k_sincosl.c: Include . (__kernel_sincosl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128ibm/k_sinl.c: Include . (__kernel_sinl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-96/k_sinl.c: Include . (__kernel_sinl): Force underflow exception for arguments with small absolute value. * sysdeps/powerpc/fpu/k_sinf.c: Include . (__kernel_sinf): Force underflow exception for arguments with small absolute value. * math/auto-libm-test-in: Add more tests of sin and sincos. * math/auto-libm-test-out: Regenerated. --- sysdeps/ieee754/ldbl-128ibm/k_sincosl.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'sysdeps/ieee754/ldbl-128ibm/k_sincosl.c') diff --git a/sysdeps/ieee754/ldbl-128ibm/k_sincosl.c b/sysdeps/ieee754/ldbl-128ibm/k_sincosl.c index f831e3f..0a76e1c 100644 --- a/sysdeps/ieee754/ldbl-128ibm/k_sincosl.c +++ b/sysdeps/ieee754/ldbl-128ibm/k_sincosl.c @@ -17,6 +17,7 @@ License along with the GNU C Library; if not, see . */ +#include #include #include @@ -112,12 +113,19 @@ __kernel_sincosl(long double x, long double y, long double *sinx, long double *c /* Argument is small enough to approximate it by a Chebyshev polynomial of degree 16(17). */ if (tix < 0x3c600000) /* |x| < 2^-57 */ - if (!((int)x)) /* generate inexact */ - { - *sinx = x; - *cosx = ONE; - return; - } + { + if (fabsl (x) < LDBL_MIN) + { + long double force_underflow = x * x; + math_force_eval (force_underflow); + } + if (!((int)x)) /* generate inexact */ + { + *sinx = x; + *cosx = ONE; + return; + } + } z = x * x; *sinx = x + (x * (z*(SIN1+z*(SIN2+z*(SIN3+z*(SIN4+ z*(SIN5+z*(SIN6+z*(SIN7+z*SIN8))))))))); -- cgit v1.1