Fix wrong ussage of sincos for subnormal arguments

This commit is contained in:
Liubov Dmitrieva 2012-09-25 20:41:17 +02:00 committed by Andreas Jaeger
parent 203e56032f
commit 6d3bf19931
19 changed files with 296 additions and 30 deletions

View File

@ -1,3 +1,25 @@
2012-09-25 Liubov Dmitrieva <liubov.dmitrieva@gmail.com>
* math/s_ccoshf.c (__ccoshf): Fix wrong using of sincosf for
subnormal argument.
* math/s_cexpf.c (__cexpf): Likewise.
* math/s_csinf.c (__csinf): Likewise.
* math/s_csinhf.c (__csinhf): Likewise.
* math/s_ctanf.c (__ctanf): Likewise.
* math/s_ctanhf.c (__ctanhf): Likewise.
* math/s_ccosh.c (__ccoshf): Likewise.
* math/s_cexp.c (__cexpl): Likewise.
* math/s_csin.c (__csin): Likewise.
* math/s_csinh.c (__csinh): Likewise.
* math/s_ctan.c (__ctan): Likewise.
* math/s_ctanh.c (ctanh): Likewise.
* math/s_ccoshl.c (__ccoshl): Likewise.
* math/s_cexpl.c (__cexpl): Likewise.
* math/s_csinl.c (__csinl): Likewise.
* math/s_csinhl.c (__csinhl): Likewise.
* math/s_ctanl.c (__ctanl): Likewise.
* math/s_ctanhl.c (__ctanhl): Likewise.
2012-09-25 Joseph Myers <joseph@codesourcery.com>
* libio/libio.h (_IO_size_t): Define to size_t, not _G_size_t.

View File

@ -39,7 +39,15 @@ __ccosh (__complex__ double x)
const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2);
double sinix, cosix;
__sincos (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincos (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0;
}
if (fabs (__real__ x) > t)
{
@ -92,7 +100,15 @@ __ccosh (__complex__ double x)
/* Imaginary part is finite. */
double sinix, cosix;
__sincos (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincos (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0;
}
__real__ retval = __copysign (HUGE_VAL, cosix);
__imag__ retval = (__copysign (HUGE_VAL, sinix)

View File

@ -39,7 +39,15 @@ __ccoshf (__complex__ float x)
const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2);
float sinix, cosix;
__sincosf (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincosf (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0f;
}
if (fabsf (__real__ x) > t)
{
@ -92,7 +100,15 @@ __ccoshf (__complex__ float x)
/* Imaginary part is finite. */
float sinix, cosix;
__sincosf (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincosf (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0f;
}
__real__ retval = __copysignf (HUGE_VALF, cosix);
__imag__ retval = (__copysignf (HUGE_VALF, sinix)

View File

@ -39,7 +39,15 @@ __ccoshl (__complex__ long double x)
const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l);
long double sinix, cosix;
__sincosl (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincosl (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0;
}
if (fabsl (__real__ x) > t)
{
@ -92,7 +100,15 @@ __ccoshl (__complex__ long double x)
/* Imaginary part is finite. */
long double sinix, cosix;
__sincosl (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincosl (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0;
}
__real__ retval = __copysignl (HUGE_VALL, cosix);
__imag__ retval = (__copysignl (HUGE_VALL, sinix)

View File

@ -39,7 +39,15 @@ __cexp (__complex__ double x)
const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2);
double sinix, cosix;
__sincos (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincos (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0;
}
if (__real__ x > t)
{
@ -95,7 +103,15 @@ __cexp (__complex__ double x)
{
double sinix, cosix;
__sincos (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincos (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0;
}
__real__ retval = __copysign (value, cosix);
__imag__ retval = __copysign (value, sinix);

View File

@ -39,7 +39,15 @@ __cexpf (__complex__ float x)
const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2);
float sinix, cosix;
__sincosf (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincosf (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0f;
}
if (__real__ x > t)
{
@ -95,7 +103,15 @@ __cexpf (__complex__ float x)
{
float sinix, cosix;
__sincosf (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincosf (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0f;
}
__real__ retval = __copysignf (value, cosix);
__imag__ retval = __copysignf (value, sinix);

View File

@ -39,7 +39,15 @@ __cexpl (__complex__ long double x)
const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l);
long double sinix, cosix;
__sincosl (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincosl (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0;
}
if (__real__ x > t)
{
@ -95,7 +103,15 @@ __cexpl (__complex__ long double x)
{
long double sinix, cosix;
__sincosl (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincosl (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0;
}
__real__ retval = __copysignl (value, cosix);
__imag__ retval = __copysignl (value, sinix);

View File

@ -42,7 +42,15 @@ __csin (__complex__ double x)
const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2);
double sinix, cosix;
__sincos (__real__ x, &sinix, &cosix);
if (__builtin_expect (rcls != FP_SUBNORMAL, 1))
{
__sincos (__real__ x, &sinix, &cosix);
}
else
{
sinix = __real__ x;
cosix = 1.0;
}
if (fabs (__imag__ x) > t)
{
@ -115,7 +123,15 @@ __csin (__complex__ double x)
/* Real part is finite. */
double sinix, cosix;
__sincos (__real__ x, &sinix, &cosix);
if (__builtin_expect (rcls != FP_SUBNORMAL, 1))
{
__sincos (__real__ x, &sinix, &cosix);
}
else
{
sinix = __real__ x;
cosix = 1.0;
}
__real__ retval = __copysign (HUGE_VAL, sinix);
__imag__ retval = __copysign (HUGE_VAL, cosix);

View File

@ -42,7 +42,15 @@ __csinf (__complex__ float x)
const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2);
float sinix, cosix;
__sincosf (__real__ x, &sinix, &cosix);
if (__builtin_expect (rcls != FP_SUBNORMAL, 1))
{
__sincosf (__real__ x, &sinix, &cosix);
}
else
{
sinix = __real__ x;
cosix = 1.0f;
}
if (fabsf (__imag__ x) > t)
{
@ -115,7 +123,15 @@ __csinf (__complex__ float x)
/* Real part is finite. */
float sinix, cosix;
__sincosf (__real__ x, &sinix, &cosix);
if (__builtin_expect (rcls != FP_SUBNORMAL, 1))
{
__sincosf (__real__ x, &sinix, &cosix);
}
else
{
sinix = __real__ x;
cosix = 1.0f;
}
__real__ retval = __copysignf (HUGE_VALF, sinix);
__imag__ retval = __copysignf (HUGE_VALF, cosix);

View File

@ -42,7 +42,15 @@ __csinh (__complex__ double x)
const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2);
double sinix, cosix;
__sincos (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincos (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0;
}
if (fabs (__real__ x) > t)
{
@ -109,7 +117,15 @@ __csinh (__complex__ double x)
/* Imaginary part is finite. */
double sinix, cosix;
__sincos (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincos (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0;
}
__real__ retval = __copysign (HUGE_VAL, cosix);
__imag__ retval = __copysign (HUGE_VAL, sinix);

View File

@ -42,7 +42,15 @@ __csinhf (__complex__ float x)
const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2);
float sinix, cosix;
__sincosf (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincosf (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0f;
}
if (fabsf (__real__ x) > t)
{
@ -109,7 +117,15 @@ __csinhf (__complex__ float x)
/* Imaginary part is finite. */
float sinix, cosix;
__sincosf (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincosf (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0f;
}
__real__ retval = __copysignf (HUGE_VALF, cosix);
__imag__ retval = __copysignf (HUGE_VALF, sinix);

View File

@ -42,7 +42,15 @@ __csinhl (__complex__ long double x)
const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l);
long double sinix, cosix;
__sincosl (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincosl (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0;
}
if (fabsl (__real__ x) > t)
{
@ -109,7 +117,15 @@ __csinhl (__complex__ long double x)
/* Imaginary part is finite. */
long double sinix, cosix;
__sincosl (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincosl (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0;
}
__real__ retval = __copysignl (HUGE_VALL, cosix);
__imag__ retval = __copysignl (HUGE_VALL, sinix);

View File

@ -42,7 +42,15 @@ __csinl (__complex__ long double x)
const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l);
long double sinix, cosix;
__sincosl (__real__ x, &sinix, &cosix);
if (__builtin_expect (rcls != FP_SUBNORMAL, 1))
{
__sincosl (__real__ x, &sinix, &cosix);
}
else
{
sinix = __real__ x;
cosix = 1.0;
}
if (fabsl (__imag__ x) > t)
{
@ -115,7 +123,15 @@ __csinl (__complex__ long double x)
/* Real part is finite. */
long double sinix, cosix;
__sincosl (__real__ x, &sinix, &cosix);
if (__builtin_expect (rcls != FP_SUBNORMAL, 1))
{
__sincosl (__real__ x, &sinix, &cosix);
}
else
{
sinix = __real__ x;
cosix = 1.0;
}
__real__ retval = __copysignl (HUGE_VALL, sinix);
__imag__ retval = __copysignl (HUGE_VALL, cosix);

View File

@ -53,11 +53,20 @@ __ctan (__complex__ double x)
double sinrx, cosrx;
double den;
const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2 / 2);
int rcls = fpclassify (__real__ x);
/* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y))
= (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */
__sincos (__real__ x, &sinrx, &cosrx);
if (__builtin_expect (rcls != FP_SUBNORMAL, 1))
{
__sincos (__real__ x, &sinrx, &cosrx);
}
else
{
sinrx = __real__ x;
cosrx = 1.0;
}
if (fabs (__imag__ x) > t)
{

View File

@ -57,7 +57,15 @@ __ctanf (__complex__ float x)
/* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y))
= (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */
__sincosf (__real__ x, &sinrx, &cosrx);
if (__builtin_expect (fpclassify(__real__ x) != FP_SUBNORMAL, 1))
{
__sincosf (__real__ x, &sinrx, &cosrx);
}
else
{
sinrx = __real__ x;
cosrx = 1.0f;
}
if (fabsf (__imag__ x) > t)
{

View File

@ -53,11 +53,20 @@ __ctanh (__complex__ double x)
double sinix, cosix;
double den;
const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2 / 2);
int icls = fpclassify (__imag__ x);
/* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y))
= (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2). */
__sincos (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincos (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0;
}
if (fabs (__real__ x) > t)
{

View File

@ -57,7 +57,15 @@ __ctanhf (__complex__ float x)
/* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y))
= (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2). */
__sincosf (__imag__ x, &sinix, &cosix);
if (__builtin_expect (fpclassify(__imag__ x) != FP_SUBNORMAL, 1))
{
__sincosf (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0f;
}
if (fabsf (__real__ x) > t)
{

View File

@ -53,11 +53,20 @@ __ctanhl (__complex__ long double x)
long double sinix, cosix;
long double den;
const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l / 2);
int icls = fpclassify (__imag__ x);
/* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y))
= (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2). */
__sincosl (__imag__ x, &sinix, &cosix);
if (__builtin_expect (icls != FP_SUBNORMAL, 1))
{
__sincosl (__imag__ x, &sinix, &cosix);
}
else
{
sinix = __imag__ x;
cosix = 1.0;
}
if (fabsl (__real__ x) > t)
{

View File

@ -53,11 +53,20 @@ __ctanl (__complex__ long double x)
long double sinrx, cosrx;
long double den;
const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l / 2);
int rcls = fpclassify (__real__ x);
/* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y))
= (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */
__sincosl (__real__ x, &sinrx, &cosrx);
if (__builtin_expect (rcls != FP_SUBNORMAL, 1))
{
__sincosl (__real__ x, &sinrx, &cosrx);
}
else
{
sinrx = __real__ x;
cosrx = 1.0;
}
if (fabsl (__imag__ x) > t)
{