diff --git a/math/s_ccoshf.c b/math/s_ccoshf.c index d6f8110..9ca57b2 100644 --- a/math/s_ccoshf.c +++ b/math/s_ccoshf.c @@ -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) diff --git a/math/s_cexpf.c b/math/s_cexpf.c index 4aa9765..41fcea5 100644 --- a/math/s_cexpf.c +++ b/math/s_cexpf.c @@ -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); diff --git a/math/s_csinf.c b/math/s_csinf.c index c1d6a4f..d53f943 100644 --- a/math/s_csinf.c +++ b/math/s_csinf.c @@ -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); diff --git a/math/s_csinhf.c b/math/s_csinhf.c index ba85e79..4b019a0 100644 --- a/math/s_csinhf.c +++ b/math/s_csinhf.c @@ -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); diff --git a/math/s_ctanf.c b/math/s_ctanf.c index 2559f83..fd2b797 100644 --- a/math/s_ctanf.c +++ b/math/s_ctanf.c @@ -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) { diff --git a/math/s_ctanhf.c b/math/s_ctanhf.c index ca36a83..862845f 100644 --- a/math/s_ctanhf.c +++ b/math/s_ctanhf.c @@ -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) { diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps index f0701ef..80c14d0 100644 --- a/sysdeps/i386/fpu/libm-test-ulps +++ b/sysdeps/i386/fpu/libm-test-ulps @@ -1490,9 +1490,9 @@ float: 1 ifloat: 1 Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i": double: 2 -float: 3 +float: 4 idouble: 2 -ifloat: 3 +ifloat: 4 ildouble: 3 ldouble: 3 Test "Imaginary part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i": @@ -1704,6 +1704,8 @@ ldouble: 1 # ctan Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i": +float: 1 +ifloat: 1 double: 1 idouble: 1 ildouble: 1 @@ -1797,6 +1799,8 @@ Test "Imaginary part of: ctan_towardzero (0x1.921fb54442d18p+0 + 0x1p-1074 i) == ildouble: 1 ldouble: 1 Test "Real part of: ctan_towardzero (0x1.921fb6p+0 + 0x1p-149 i) == -2.287733242885645987394874673945769518150e7 + 7.334008549954377778731880988481078535821e-31 i": +float: 1 +ifloat: 1 ildouble: 1 ldouble: 1 Test "Imaginary part of: ctan_towardzero (0x1.921fb6p+0 + 0x1p-149 i) == -2.287733242885645987394874673945769518150e7 + 7.334008549954377778731880988481078535821e-31 i": @@ -1827,9 +1831,9 @@ ildouble: 2 ldouble: 2 Test "Imaginary part of: ctan_upward (0x1.921fb6p+0 + 0x1p-149 i) == -2.287733242885645987394874673945769518150e7 + 7.334008549954377778731880988481078535821e-31 i": double: 1 -float: 1 +float: 2 idouble: 1 -ifloat: 1 +ifloat: 2 ildouble: 1 ldouble: 1 @@ -1940,6 +1944,8 @@ ifloat: 3 ildouble: 4 ldouble: 4 Test "Imaginary part of: ctanh_towardzero (0x1p-149 + 0x1.921fb6p+0 i) == 7.334008549954377778731880988481078535821e-31 - 2.287733242885645987394874673945769518150e7 i": +float: 1 +ifloat: 1 ildouble: 1 ldouble: 1 @@ -1954,9 +1960,9 @@ ildouble: 1 ldouble: 1 Test "Real part of: ctanh_upward (0x1p-149 + 0x1.921fb6p+0 i) == 7.334008549954377778731880988481078535821e-31 - 2.287733242885645987394874673945769518150e7 i": double: 1 -float: 1 +float: 2 idouble: 1 -ifloat: 1 +ifloat: 2 ildouble: 1 ldouble: 1 Test "Imaginary part of: ctanh_upward (0x1p-149 + 0x1.921fb6p+0 i) == 7.334008549954377778731880988481078535821e-31 - 2.287733242885645987394874673945769518150e7 i": @@ -2556,9 +2562,6 @@ ifloat: 1 Test "sincos (-0x1p65, &sin_res, &cos_res) puts 0.047183876212354673805106149805700013943218 in sin_res": float: 1 ifloat: 1 -Test "sincos (0x1p+50, &sin_res, &cos_res) puts 8.68095904660550604334592502063501320395739e-01 in cos_res": -float: 1 -ifloat: 1 Test "sincos (0x1p65, &sin_res, &cos_res) puts -0.047183876212354673805106149805700013943218 in sin_res": float: 1 ifloat: 1 @@ -3434,6 +3437,8 @@ ildouble: 1 ldouble: 1 Function: Real part of "ctan_towardzero": +float: 1 +ifloat: 1 double: 1 idouble: 1 ildouble: 1 @@ -3453,9 +3458,9 @@ ldouble: 2 Function: Imaginary part of "ctan_upward": double: 1 -float: 1 +float: 2 idouble: 1 -ifloat: 1 +ifloat: 2 ildouble: 4 ldouble: 4 @@ -3506,6 +3511,8 @@ ildouble: 4 ldouble: 4 Function: Imaginary part of "ctanh_towardzero": +float: 1 +ifloat: 1 double: 1 idouble: 1 ildouble: 1 @@ -3513,9 +3520,9 @@ ldouble: 1 Function: Real part of "ctanh_upward": double: 1 -float: 1 +float: 2 idouble: 1 -ifloat: 1 +ifloat: 2 ildouble: 4 ldouble: 4 diff --git a/sysdeps/i386/i686/fpu/multiarch/Makefile b/sysdeps/i386/i686/fpu/multiarch/Makefile index aa28f72..7d90892 100644 --- a/sysdeps/i386/i686/fpu/multiarch/Makefile +++ b/sysdeps/i386/i686/fpu/multiarch/Makefile @@ -1,3 +1,4 @@ ifeq ($(subdir),math) -libm-sysdep_routines += e_expf-sse2 e_expf-ia32 s_sinf-sse2 s_cosf-sse2 +libm-sysdep_routines += e_expf-sse2 e_expf-ia32 s_sinf-sse2 s_cosf-sse2 \ + s_sincosf-sse2 endif diff --git a/sysdeps/i386/i686/fpu/multiarch/s_cosf-sse2.S b/sysdeps/i386/i686/fpu/multiarch/s_cosf-sse2.S index 2b5a2a5..405c6ea 100644 --- a/sysdeps/i386/i686/fpu/multiarch/s_cosf-sse2.S +++ b/sysdeps/i386/i686/fpu/multiarch/s_cosf-sse2.S @@ -50,25 +50,29 @@ * 9) if x is NaN, return x-x. * * Special cases: - * cos(+-0)==+-0 not raising inexact/underflow, - * cos(subnormal) raises inexact/underflow - * cos(min_normalized) raises inexact/underflow - * cos(normalized) raises inexact - * cos(Inf) = NaN, raises invalid, sets errno to EDOM - * cos(NaN) = NaN + * cos(+-0) = 1 not raising inexact, + * cos(subnormal) raises inexact, + * cos(min_normalized) raises inexact, + * cos(normalized) raises inexact, + * cos(Inf) = NaN, raises invalid, sets errno to EDOM, + * cos(NaN) = NaN. */ #ifdef PIC # define MO1(symbol) L(symbol)##@GOTOFF(%ebx) # define MO2(symbol,reg2,_scale) L(symbol)##@GOTOFF(%ebx,reg2,_scale) -# define SAVE_BX pushl %ebx -# define RESTORE_BX popl %ebx +# define CFI_PUSH(REG) cfi_adjust_cfa_offset(4); cfi_rel_offset(REG,0) +# define CFI_POP(REG) cfi_adjust_cfa_offset(-4); cfi_restore(REG) +# define PUSH(REG) pushl REG; CFI_PUSH(REG) +# define POP(REG) popl REG; CFI_POP(REG) +# define ENTRANCE PUSH(%ebx); LOAD_PIC_REG(bx) +# define RETURN POP(%ebx); ret; CFI_PUSH(%ebx) # define ARG_X 8(%esp) #else # define MO1(symbol) L(symbol) # define MO2(symbol,reg2,_scale) L(symbol)(,reg2,_scale) -# define SAVE_BX -# define RESTORE_BX +# define ENTRANCE +# define RETURN ret # define ARG_X 4(%esp) #endif @@ -76,11 +80,7 @@ ENTRY(__cosf_sse2) /* Input: single precision x on stack at address ARG_X */ -#ifdef PIC - SAVE_BX - LOAD_PIC_REG(bx) -#endif - + ENTRANCE movl ARG_X, %eax /* Bits of x */ cvtss2sd ARG_X, %xmm0 /* DP x */ andl $0x7fffffff, %eax /* |x| */ @@ -143,8 +143,7 @@ L(reconstruction): fldl 0(%esp) /* ...to FPU. */ /* Return back 4 bytes of stack frame */ lea 8(%esp), %esp - RESTORE_BX - ret + RETURN .p2align 4 L(sin_poly): @@ -183,9 +182,7 @@ L(sin_poly): fldl 0(%esp) /* ...to FPU. */ /* Return back 4 bytes of stack frame */ lea 8(%esp), %esp - RESTORE_BX - ret - + RETURN .p2align 4 L(large_args): @@ -275,7 +272,6 @@ L(very_large_skip2): jmp L(reconstruction) /* end of very_large_args peth */ - .p2align 4 L(arg_less_pio4): /* Here if |x|. */ + +#include +#define __need_Emath +#include + +/* Short algorithm description: + * + * 1) if |x|==0: sin(x)=x, + * cos(x)=1. + * 2) if |x|<2^-27: sin(x)=x-x*DP_SMALL, raising underflow only when needed, + * cos(x)=1-|x|. + * 3) if |x|<2^-5 : sin(x)=x+x*x^2*DP_SIN2_0+x^5*DP_SIN2_1, + * cos(x)=1+1*x^2*DP_COS2_0+x^5*DP_COS2_1 + * 4) if |x|< Pi/4: sin(x)=x+x*x^2*(S0+x^2*(S1+x^2*(S2+x^2*(S3+x^2*S4)))), + * cos(x)=1+1*x^2*(C0+x^2*(C1+x^2*(C2+x^2*(C3+x^2*C4)))). + * 5) if |x| < 9*Pi/4: + * 5.1) Range reduction: + * k=trunc(|x|/(Pi/4)), j=(k+1)&0x0e, n=k+1, t=|x|-j*Pi/4. + * 5.2) Reconstruction: + * sign_sin = sign(x) * (-1.0)^(( n >>2)&1) + * sign_cos = (-1.0)^(((n+2)>>2)&1) + * poly_sin = ((((S4*t^2 + S3)*t^2 + S2)*t^2 + S1)*t^2 + S0)*t^2*t+t + * poly_cos = ((((C4*t^2 + C3)*t^2 + C2)*t^2 + C1)*t^2 + C0)*t^2*s+s + * if(n&2 != 0) { + * using cos(t) and sin(t) polynomials for |t|= 2^23, very large args: + * 7.1) Range reduction: + * k=trunc(|x|/(Pi/4)), j=(k+1)&0xfffffffe, n=k+1, t=|x|-j*Pi/4. + * 7.2) Reconstruction same as (5.2). + * 8) if x is Inf, return x-x, and set errno=EDOM. + * 9) if x is NaN, return x-x. + * + * Special cases: + * sin/cos(+-0) = +-0/1 not raising inexact/underflow, + * sin/cos(subnormal) raises inexact/underflow, + * sin/cos(min_normalized) raises inexact/underflow, + * sin/cos(normalized) raises inexact, + * sin/cos(Inf) = NaN, raises invalid, sets errno to EDOM, + * sin/cos(NaN) = NaN. + */ + +#ifdef PIC +# define MO1(symbol) L(symbol)##@GOTOFF(%ebx) +# define MO2(symbol,reg2,_scale) L(symbol)##@GOTOFF(%ebx,reg2,_scale) +# define CFI_PUSH(REG) cfi_adjust_cfa_offset(4); cfi_rel_offset(REG,0) +# define CFI_POP(REG) cfi_adjust_cfa_offset(-4); cfi_restore(REG) +# define PUSH(REG) pushl REG; CFI_PUSH(REG) +# define POP(REG) popl REG; CFI_POP(REG) +# define ENTRANCE PUSH(%ebx); LOAD_PIC_REG(bx) +# define RETURN POP(%ebx); ret; CFI_PUSH(%ebx) +# define ARG_X 8(%esp) +# define ARG_SIN_PTR 12(%esp) +# define ARG_COS_PTR 16(%esp) +#else +# define MO1(symbol) L(symbol) +# define MO2(symbol,reg2,_scale) L(symbol)(,reg2,_scale) +# define ENTRANCE +# define RETURN ret +# define ARG_X 4(%esp) +# define ARG_SIN_PTR 8(%esp) +# define ARG_COS_PTR 12(%esp) +#endif + + .text +ENTRY(__sincosf_sse2) + /* Input: single precision x on stack at address ARG_X */ + /* pointer to sin result on stack at address ARG_SIN_PTR */ + /* pointer to cos result on stack at address ARG_COS_PTR */ + + ENTRANCE + movl ARG_X, %eax /* Bits of x */ + cvtss2sd ARG_X, %xmm0 /* DP x */ + andl $0x7fffffff, %eax /* |x| */ + + cmpl $0x3f490fdb, %eax /* |x|=Pi/4 */ + movd %eax, %xmm3 /* SP |x| */ + andpd MO1(DP_ABS_MASK),%xmm0 /* DP |x| */ + movss MO1(SP_INVPIO4), %xmm2 /* SP 1/(Pi/4) */ + + cmpl $0x40e231d6, %eax /* |x|<9*Pi/4 ? */ + jae L(large_args) + + /* Here if Pi/4<=|x|<9*Pi/4 */ + mulss %xmm3, %xmm2 /* SP |x|/(Pi/4) */ + movl ARG_X, %ecx /* Load x */ + cvttss2si %xmm2, %eax /* k, number of Pi/4 in x */ + shrl $29, %ecx /* (sign of x) << 2 */ + addl $1, %eax /* k+1 */ + movl $0x0e, %edx + andl %eax, %edx /* j = (k+1)&0x0e */ + subsd MO2(PIO4J,%edx,8), %xmm0/* t = |x| - j * Pi/4 */ + +L(reconstruction): + /* Input: %eax=n, %xmm0=t, %ecx=sign(x) */ + + movaps %xmm0, %xmm4 /* t */ + movhpd MO1(DP_ONES), %xmm4 /* 1|t */ + mulsd %xmm0, %xmm0 /* y=t^2 */ + movl $2, %edx + unpcklpd %xmm0, %xmm0 /* y|y */ + addl %eax, %edx /* k+2 */ + movaps %xmm0, %xmm1 /* y|y */ + mulpd %xmm0, %xmm0 /* z=t^4|z=t^4 */ + + movaps MO1(DP_SC4), %xmm2 /* S4 */ + mulpd %xmm0, %xmm2 /* z*S4 */ + movaps MO1(DP_SC3), %xmm3 /* S3 */ + mulpd %xmm0, %xmm3 /* z*S3 */ + xorl %eax, %ecx /* (sign_x ^ (k>>2))<<2 */ + addpd MO1(DP_SC2), %xmm2 /* S2+z*S4 */ + mulpd %xmm0, %xmm2 /* z*(S2+z*S4) */ + shrl $2, %edx /* (k+2)>>2 */ + addpd MO1(DP_SC1), %xmm3 /* S1+z*S3 */ + mulpd %xmm0, %xmm3 /* z*(S1+z*S3) */ + shrl $2, %ecx /* sign_x ^ k>>2 */ + addpd MO1(DP_SC0), %xmm2 /* S0+z*(S2+z*S4) */ + andl $1, %edx /* sign_cos = ((k+2)>>2)&1 */ + mulpd %xmm1, %xmm2 /* y*(S0+z*(S2+z*S4)) */ + andl $1, %ecx /* sign_sin = sign_x ^ ((k>>2)&1) */ + addpd %xmm2, %xmm3 /* y*(S0+y*(S1+y*(S2+y*(S3+y*S4)))) */ + mulpd %xmm4, %xmm3 /*t*y*(S0+y*(S1+y*(S2+y*(S3+y*S4))))*/ + testl $2, %eax /* n&2 != 0 ? */ + addpd %xmm4, %xmm3 /*t+t*y*(S0+y*(S1+y*(S2+y*(S3+y*S4))*/ + jnz L(sin_result_sin_poly) + +/*L(sin_result_cos_poly):*/ + /* + * Here if + * cos(x) = poly_sin * sign_cos + * sin(x) = poly_cos * sign_sin + */ + movsd MO2(DP_ONES,%ecx,8), %xmm4/* 0|sign_sin */ + movhpd MO2(DP_ONES,%edx,8), %xmm4/* sign_cos|sign_sin */ + mulpd %xmm4, %xmm3 /* result_cos|result_sin */ + movl ARG_SIN_PTR, %eax + cvtpd2ps %xmm3, %xmm0 /* SP results */ + movl ARG_COS_PTR, %ecx + movss %xmm0, (%eax) /* store sin(x) from xmm0[0] */ + shufps $1, %xmm0, %xmm0 /* move cos(x) to xmm0[0] */ + movss %xmm0, (%ecx) /* store cos(x) */ + RETURN + + .p2align 4 +L(sin_result_sin_poly): + /* + * Here if + * sin(x) = poly_sin * sign_sin + * cos(x) = poly_cos * sign_cos + */ + movsd MO2(DP_ONES,%edx,8), %xmm4/* 0|sign_cos */ + movhpd MO2(DP_ONES,%ecx,8), %xmm4/* sign_sin|sign_cos */ + mulpd %xmm4, %xmm3 /* result_sin|result_cos */ + movl ARG_SIN_PTR, %eax + cvtpd2ps %xmm3, %xmm0 /* SP results */ + movl ARG_COS_PTR, %ecx + movss %xmm0, (%ecx) /* store cos(x) from xmm0[0] */ + shufps $1, %xmm0, %xmm0 /* move sin(x) to xmm0[0] */ + movss %xmm0, (%eax) /* store sin(x) */ + RETURN + + .p2align 4 +L(large_args): + /* Here if |x|>=9*Pi/4 */ + cmpl $0x7f800000, %eax /* x is Inf or NaN ? */ + jae L(arg_inf_or_nan) + + /* Here if finite |x|>=9*Pi/4 */ + cmpl $0x4b000000, %eax /* |x|<2^23 ? */ + jae L(very_large_args) + + /* Here if 9*Pi/4<=|x|<2^23 */ + movsd MO1(DP_INVPIO4), %xmm1 /* 1/(Pi/4) */ + mulsd %xmm0, %xmm1 /* |x|/(Pi/4) */ + cvttsd2si %xmm1, %eax /* k=trunc(|x|/(Pi/4)) */ + addl $1, %eax /* k+1 */ + movl %eax, %edx + andl $0xfffffffe, %edx /* j=(k+1)&0xfffffffe */ + cvtsi2sdl %edx, %xmm4 /* DP j */ + movl ARG_X, %ecx /* Load x */ + movsd MO1(DP_PIO4HI), %xmm2 /* -PIO4HI = high part of -Pi/4 */ + shrl $29, %ecx /* (sign of x) << 2 */ + mulsd %xmm4, %xmm2 /* -j*PIO4HI */ + movsd MO1(DP_PIO4LO), %xmm3 /* -PIO4LO = low part of -Pi/4 */ + addsd %xmm2, %xmm0 /* |x| - j*PIO4HI */ + mulsd %xmm3, %xmm4 /* j*PIO4LO */ + addsd %xmm4, %xmm0 /* t = |x| - j*PIO4HI - j*PIO4LO */ + jmp L(reconstruction) + + .p2align 4 +L(very_large_args): + /* Here if finite |x|>=2^23 */ + + /* bitpos = (ix>>23) - BIAS_32 + 59; */ + shrl $23, %eax /* eb = biased exponent of x */ + subl $68, %eax /* bitpos=eb-0x7f+59, where 0x7f */ + /*is exponent bias */ + movl $28, %ecx /* %cl=28 */ + movl %eax, %edx /* bitpos copy */ + + /* j = bitpos/28; */ + div %cl /* j in register %al=%ax/%cl */ + movapd %xmm0, %xmm3 /* |x| */ + andl $0xff, %eax /* clear unneeded remainder from %ah*/ + + imull $28, %eax, %ecx /* j*28 */ + movsd MO1(DP_HI_MASK), %xmm4 /* DP_HI_MASK */ + movapd %xmm0, %xmm5 /* |x| */ + mulsd -2*8+MO2(_FPI,%eax,8), %xmm3/* tmp3 = FPI[j-2]*|x| */ + movapd %xmm0, %xmm1 /* |x| */ + mulsd -1*8+MO2(_FPI,%eax,8), %xmm5/* tmp2 = FPI[j-1]*|x| */ + mulsd 0*8+MO2(_FPI,%eax,8), %xmm0/* tmp0 = FPI[j]*|x| */ + addl $19, %ecx /* j*28+19 */ + mulsd 1*8+MO2(_FPI,%eax,8), %xmm1/* tmp1 = FPI[j+1]*|x| */ + cmpl %ecx, %edx /* bitpos>=j*28+19 ? */ + jl L(very_large_skip1) + + /* Here if bitpos>=j*28+19 */ + andpd %xmm3, %xmm4 /* HI(tmp3) */ + subsd %xmm4, %xmm3 /* tmp3 = tmp3 - HI(tmp3) */ +L(very_large_skip1): + + movsd MO1(DP_2POW52), %xmm6 + movapd %xmm5, %xmm2 /* tmp2 copy */ + addsd %xmm3, %xmm5 /* tmp5 = tmp3 + tmp2 */ + movl $1, %edx + addsd %xmm5, %xmm6 /* tmp6 = tmp5 + 2^52 */ + movsd 8+MO1(DP_2POW52), %xmm4 + movd %xmm6, %eax /* k = I64_LO(tmp6); */ + addsd %xmm6, %xmm4 /* tmp4 = tmp6 - 2^52 */ + movl ARG_X, %ecx /* Load x */ + comisd %xmm5, %xmm4 /* tmp4 > tmp5 ? */ + jbe L(very_large_skip2) + + /* Here if tmp4 > tmp5 */ + subl $1, %eax /* k-- */ + addsd 8+MO1(DP_ONES), %xmm4 /* tmp4 -= 1.0 */ +L(very_large_skip2): + + andl %eax, %edx /* k&1 */ + subsd %xmm4, %xmm3 /* tmp3 -= tmp4 */ + addsd MO2(DP_ZERONE,%edx,8), %xmm3/* t = DP_ZERONE[k&1] + tmp3 */ + addsd %xmm2, %xmm3 /* t += tmp2 */ + shrl $29, %ecx /* (sign of x) << 2 */ + addsd %xmm3, %xmm0 /* t += tmp0 */ + addl $1, %eax /* n=k+1 */ + addsd %xmm1, %xmm0 /* t += tmp1 */ + mulsd MO1(DP_PIO4), %xmm0 /* t *= PI04 */ + + jmp L(reconstruction) /* end of very_large_args peth */ + + .p2align 4 +L(arg_less_pio4): + /* Here if |x|. */ + +#include + +extern void __sincosf_sse2 (float, float *, float *); +extern void __sincosf_ia32 (float, float *, float *); +void __sincosf (float, float *, float *); + +libm_ifunc (__sincosf, HAS_SSE2 ? __sincosf_sse2 : __sincosf_ia32); +weak_alias (__sincosf, sincosf); + +#define SINCOSF __sincosf_ia32 +#include diff --git a/sysdeps/i386/i686/fpu/multiarch/s_sinf-sse2.S b/sysdeps/i386/i686/fpu/multiarch/s_sinf-sse2.S index cda1750..49d59b5 100644 --- a/sysdeps/i386/i686/fpu/multiarch/s_sinf-sse2.S +++ b/sysdeps/i386/i686/fpu/multiarch/s_sinf-sse2.S @@ -50,25 +50,29 @@ * 9) if x is NaN, return x-x. * * Special cases: - * sin(+-0)==+-0 not raising inexact/underflow, - * sin(subnormal) raises inexact/underflow - * sin(min_normalized) raises inexact/underflow - * sin(normalized) raises inexact - * sin(Inf) = NaN, raises invalid, sets errno to EDOM - * sin(NaN) = NaN + * sin(+-0) = +-0 not raising inexact/underflow, + * sin(subnormal) raises inexact/underflow, + * sin(min_normalized) raises inexact/underflow, + * sin(normalized) raises inexact, + * sin(Inf) = NaN, raises invalid, sets errno to EDOM, + * sin(NaN) = NaN. */ #ifdef PIC # define MO1(symbol) L(symbol)##@GOTOFF(%ebx) # define MO2(symbol,reg2,_scale) L(symbol)##@GOTOFF(%ebx,reg2,_scale) -# define SAVE_BX pushl %ebx -# define RESTORE_BX popl %ebx +# define CFI_PUSH(REG) cfi_adjust_cfa_offset(4); cfi_rel_offset(REG,0) +# define CFI_POP(REG) cfi_adjust_cfa_offset(-4); cfi_restore(REG) +# define PUSH(REG) pushl REG; CFI_PUSH(REG) +# define POP(REG) popl REG; CFI_POP(REG) +# define ENTRANCE PUSH(%ebx); LOAD_PIC_REG(bx) +# define RETURN POP(%ebx); ret; CFI_PUSH(%ebx) # define ARG_X 8(%esp) #else # define MO1(symbol) L(symbol) # define MO2(symbol,reg2,_scale) L(symbol)(,reg2,_scale) -# define SAVE_BX -# define RESTORE_BX +# define ENTRANCE +# define RETURN ret # define ARG_X 4(%esp) #endif @@ -76,11 +80,7 @@ ENTRY(__sinf_sse2) /* Input: single precision x on stack at address ARG_X */ -#ifdef PIC - SAVE_BX - LOAD_PIC_REG(bx) -#endif - + ENTRANCE movl ARG_X, %eax /* Bits of x */ cvtss2sd ARG_X, %xmm0 /* DP x */ andl $0x7fffffff, %eax /* |x| */ @@ -145,8 +145,7 @@ L(reconstruction): fldl 0(%esp) /* ...to FPU. */ /* Return back 4 bytes of stack frame */ lea 8(%esp), %esp - RESTORE_BX - ret + RETURN .p2align 4 L(sin_poly): @@ -186,9 +185,7 @@ L(sin_poly): fldl 0(%esp) /* ...to FPU. */ /* Return back 4 bytes of stack frame */ lea 8(%esp), %esp - RESTORE_BX - ret - + RETURN .p2align 4 L(large_args): @@ -281,10 +278,6 @@ L(very_large_skip2): jmp L(reconstruction) /* end of very_large_args peth */ - - - - .p2align 4 L(arg_less_pio4): /* Here if |x| +#ifndef SINCOSF +# define SINCOSF_FUNC __sincosf +#else +# define SINCOSF_FUNC SINCOSF +#endif void -__sincosf (float x, float *sinx, float *cosx) +SINCOSF_FUNC (float x, float *sinx, float *cosx) { int32_t ix; @@ -70,4 +75,7 @@ __sincosf (float x, float *sinx, float *cosx) } } } + +#ifndef SINCOSF weak_alias (__sincosf, sincosf) +#endif diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps index b02b9e6..d79578c 100644 --- a/sysdeps/x86_64/fpu/libm-test-ulps +++ b/sysdeps/x86_64/fpu/libm-test-ulps @@ -1579,6 +1579,9 @@ ildouble: 1 ldouble: 1 # ctan +Test "Real part of: ctan (0x1p127 + 1 i) == 0.2446359391192790896381501310437708987204 + 0.9101334047676183761532873794426475906201 i": +float: 1 +ifloat: 1 Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i": double: 1 float: 1 @@ -1612,6 +1615,8 @@ Test "Imaginary part of: ctan (0x1p1023 + 1 i) == -0.225462792499754505792678258 ildouble: 1 ldouble: 1 Test "Imaginary part of: ctan (0x1p127 + 1 i) == 0.2446359391192790896381501310437708987204 + 0.9101334047676183761532873794426475906201 i": +float: 2 +ifloat: 2 double: 1 idouble: 1 Test "Real part of: ctan (0x3.243f6cp-1 + 0 i) == -2.287733242885645987394874673945769518150e7 + 0.0 i": @@ -1757,6 +1762,8 @@ idouble: 1 ildouble: 1 ldouble: 1 Test "Real part of: ctanh (1 + 0x1p127 i) == 0.9101334047676183761532873794426475906201 + 0.2446359391192790896381501310437708987204 i": +float: 2 +ifloat: 2 double: 1 idouble: 1 Test "Imaginary part of: ctanh (45 + 1 i) == 1.000000000000000000000000000000000000001 + 1.490158918874345552942703234806348520895e-39 i": @@ -1765,6 +1772,9 @@ ldouble: 1 Test "Imaginary part of: ctanh (47 + 1 i) == 1.0 + 2.729321264492904590777293425576722354636e-41 i": ildouble: 2 ldouble: 2 +Test "Imaginary part of: ctanh (1 + 0x1p127 i) == 0.9101334047676183761532873794426475906201 + 0.2446359391192790896381501310437708987204 i": +float: 1 +ifloat: 1 # ctanh_downward Test "Real part of: ctanh_downward (0x1p-1074 + 0x1.921fb54442d18p+0 i) == 1.317719414943508315995636961402669067843e-291 + 1.633123935319536975596773704152891653086e16 i": @@ -2399,8 +2409,8 @@ ifloat: 2 ildouble: 1 ldouble: 1 Test "sin_upward (3) == 0.1411200080598672221007448028081102798469": -float: 1 -ifloat: 1 +float: 2 +ifloat: 2 ildouble: 1 ldouble: 1 Test "sin_upward (4) == -0.7568024953079282513726390945118290941359": @@ -2430,12 +2440,6 @@ ifloat: 1 Test "sincos (0.80190127184058835, &sin_res, &cos_res) puts 0.69534156199418473 in cos_res": double: 1 idouble: 1 -Test "sincos (0x1p+120, &sin_res, &cos_res) puts -9.25879022854837867303861764107414946730833e-01 in cos_res": -float: 1 -ifloat: 1 -Test "sincos (0x1p+127, &sin_res, &cos_res) puts 7.81914638714960072263910298466369236613162e-01 in cos_res": -float: 1 -ifloat: 1 Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res": double: 1 float: 1 @@ -2705,6 +2709,8 @@ Test "y1 (0x1.001000001p+593) == 3.927269966354206207832593635798954916263e-90": ildouble: 2 ldouble: 2 Test "y1 (0x1.27e204p+99) == -8.881610148467797208469612080785210013461e-16": +float: 1 +ifloat: 1 double: 1 idouble: 1 ildouble: 1 @@ -3085,8 +3091,8 @@ ildouble: 1 ldouble: 1 Function: "cos_upward": -float: 1 -ifloat: 1 +float: 2 +ifloat: 2 ildouble: 1 ldouble: 1 @@ -3174,17 +3180,17 @@ ldouble: 1 Function: Real part of "ctan": double: 1 -float: 1 +float: 2 idouble: 1 -ifloat: 1 +ifloat: 2 ildouble: 2 ldouble: 2 Function: Imaginary part of "ctan": double: 1 -float: 1 +float: 2 idouble: 1 -ifloat: 1 +ifloat: 2 ildouble: 1 ldouble: 1 @@ -3242,9 +3248,9 @@ ldouble: 4 Function: Real part of "ctanh": double: 1 -float: 1 +float: 2 idouble: 1 -ifloat: 1 +ifloat: 2 ildouble: 1 ldouble: 1 @@ -3445,8 +3451,8 @@ ildouble: 1 ldouble: 1 Function: "sin_upward": -float: 1 -ifloat: 1 +float: 2 +ifloat: 2 ildouble: 1 ldouble: 1 diff --git a/sysdeps/x86_64/fpu/s_cosf.S b/sysdeps/x86_64/fpu/s_cosf.S index 7eeefe8..dc8c76a 100644 --- a/sysdeps/x86_64/fpu/s_cosf.S +++ b/sysdeps/x86_64/fpu/s_cosf.S @@ -50,12 +50,12 @@ * 9) if x is NaN, return x-x. * * Special cases: - * cos(+-0)==+-0 not raising inexact/underflow, - * cos(subnormal) raises inexact/underflow - * cos(min_normalized) raises inexact/underflow - * cos(normalized) raises inexact - * cos(Inf) = NaN, raises invalid, sets errno to EDOM - * cos(NaN) = NaN + * cos(+-0) = 1 not raising inexact, + * cos(subnormal) raises inexact, + * cos(min_normalized) raises inexact, + * cos(normalized) raises inexact, + * cos(Inf) = NaN, raises invalid, sets errno to EDOM, + * cos(NaN) = NaN. */ .text @@ -163,10 +163,6 @@ L(sin_poly): cvtsd2ss %xmm3, %xmm0 /* SP result */ ret - - - - .p2align 4 L(large_args): /* Here if |x|>=9*Pi/4 */ @@ -257,7 +253,6 @@ L(very_large_skip2): jmp L(reconstruction) /* end of very_large_args peth */ - .p2align 4 L(arg_less_pio4): /* Here if |x|. */ + +#include +#define __need_Emath +#include + +/* Short algorithm description: + * + * 1) if |x|==0: sin(x)=x, + * cos(x)=1. + * 2) if |x|<2^-27: sin(x)=x-x*DP_SMALL, raising underflow only when needed, + * cos(x)=1-|x|. + * 3) if |x|<2^-5 : sin(x)=x+x*x^2*DP_SIN2_0+x^5*DP_SIN2_1, + * cos(x)=1+1*x^2*DP_COS2_0+x^5*DP_COS2_1 + * 4) if |x|< Pi/4: sin(x)=x+x*x^2*(S0+x^2*(S1+x^2*(S2+x^2*(S3+x^2*S4)))), + * cos(x)=1+1*x^2*(C0+x^2*(C1+x^2*(C2+x^2*(C3+x^2*C4)))). + * 5) if |x| < 9*Pi/4: + * 5.1) Range reduction: + * k=trunc(|x|/(Pi/4)), j=(k+1)&0x0e, n=k+1, t=|x|-j*Pi/4. + * 5.2) Reconstruction: + * sign_sin = sign(x) * (-1.0)^(( n >>2)&1) + * sign_cos = (-1.0)^(((n+2)>>2)&1) + * poly_sin = ((((S4*t^2 + S3)*t^2 + S2)*t^2 + S1)*t^2 + S0)*t^2*t+t + * poly_cos = ((((C4*t^2 + C3)*t^2 + C2)*t^2 + C1)*t^2 + C0)*t^2*s+s + * if(n&2 != 0) { + * using cos(t) and sin(t) polynomials for |t|= 2^23, very large args: + * 7.1) Range reduction: + * k=trunc(|x|/(Pi/4)), j=(k+1)&0xfffffffe, n=k+1, t=|x|-j*Pi/4. + * 7.2) Reconstruction same as (5.2). + * 8) if x is Inf, return x-x, and set errno=EDOM. + * 9) if x is NaN, return x-x. + * + * Special cases: + * sin/cos(+-0) = +-0/1 not raising inexact/underflow, + * sin/cos(subnormal) raises inexact/underflow, + * sin/cos(min_normalized) raises inexact/underflow, + * sin/cos(normalized) raises inexact, + * sin/cos(Inf) = NaN, raises invalid, sets errno to EDOM, + * sin/cos(NaN) = NaN. + */ + +# define ARG_SIN_PTR %rdi +# define ARG_COS_PTR %rsi + + .text +ENTRY(__sincosf) + /* Input: %xmm0 contains single precision argument x */ + /* %rdi points to sin result */ + /* %rsi points to cos result */ + + movd %xmm0, %eax /* Bits of x */ + movaps %xmm0, %xmm7 /* Copy of x */ + cvtss2sd %xmm0, %xmm0 /* DP x */ + movss L(SP_ABS_MASK)(%rip), %xmm3 + movl %eax, %r8d /* Copy of x bits */ + andl $0x7fffffff, %eax /* |x| */ + + cmpl $0x3f490fdb, %eax /* |x|=Pi/4 */ + andps %xmm7, %xmm3 /* SP |x| */ + andpd L(DP_ABS_MASK)(%rip),%xmm0 /* DP |x| */ + movss L(SP_INVPIO4)(%rip), %xmm2 /* SP 1/(Pi/4) */ + + cmpl $0x40e231d6, %eax /* |x|<9*Pi/4 ? */ + jae L(large_args) + + /* Here if Pi/4<=|x|<9*Pi/4 */ + mulss %xmm3, %xmm2 /* SP |x|/(Pi/4) */ + movl %r8d, %ecx /* Load x */ + cvttss2si %xmm2, %eax /* k, number of Pi/4 in x */ + lea L(PIO4J)(%rip), %r9 + shrl $29, %ecx /* (sign of x) << 2 */ + addl $1, %eax /* k+1 */ + movl $0x0e, %edx + andl %eax, %edx /* j = (k+1)&0x0e */ + subsd (%r9,%rdx,8), %xmm0 /* t = |x| - j * Pi/4 */ + +L(reconstruction): + /* Input: %eax=n, %xmm0=t, %ecx=sign(x) */ + + movaps %xmm0, %xmm4 /* t */ + movhpd L(DP_ONES)(%rip), %xmm4 /* 1|t */ + mulsd %xmm0, %xmm0 /* y=t^2 */ + movl $2, %edx + unpcklpd %xmm0, %xmm0 /* y|y */ + addl %eax, %edx /* k+2 */ + movaps %xmm0, %xmm1 /* y|y */ + mulpd %xmm0, %xmm0 /* z=t^4|z=t^4 */ + + movaps L(DP_SC4)(%rip), %xmm2 /* S4 */ + mulpd %xmm0, %xmm2 /* z*S4 */ + movaps L(DP_SC3)(%rip), %xmm3 /* S3 */ + mulpd %xmm0, %xmm3 /* z*S3 */ + xorl %eax, %ecx /* (sign_x ^ (k>>2))<<2 */ + addpd L(DP_SC2)(%rip), %xmm2 /* S2+z*S4 */ + mulpd %xmm0, %xmm2 /* z*(S2+z*S4) */ + shrl $2, %edx /* (k+2)>>2 */ + addpd L(DP_SC1)(%rip), %xmm3 /* S1+z*S3 */ + mulpd %xmm0, %xmm3 /* z*(S1+z*S3) */ + shrl $2, %ecx /* sign_x ^ k>>2 */ + addpd L(DP_SC0)(%rip), %xmm2 /* S0+z*(S2+z*S4) */ + andl $1, %edx /* sign_cos = ((k+2)>>2)&1 */ + mulpd %xmm1, %xmm2 /* y*(S0+z*(S2+z*S4)) */ + andl $1, %ecx /* sign_sin = sign_x ^ ((k>>2)&1) */ + addpd %xmm2, %xmm3 /* y*(S0+y*(S1+y*(S2+y*(S3+y*S4)))) */ + lea L(DP_ONES)(%rip), %r9 + mulpd %xmm4, %xmm3 /*t*y*(S0+y*(S1+y*(S2+y*(S3+y*S4))))*/ + testl $2, %eax /* n&2 != 0 ? */ + addpd %xmm4, %xmm3 /*t+t*y*(S0+y*(S1+y*(S2+y*(S3+y*S4))*/ + jnz L(sin_result_sin_poly) + +/*L(sin_result_cos_poly):*/ + /* + * Here if + * cos(x) = poly_sin * sign_cos + * sin(x) = poly_cos * sign_sin + */ + movsd (%r9,%rcx,8), %xmm4 /* 0|sign_sin */ + movhpd (%r9,%rdx,8), %xmm4 /* sign_cos|sign_sin */ + mulpd %xmm4, %xmm3 /* result_cos|result_sin */ + cvtpd2ps %xmm3, %xmm0 /* SP results */ + movss %xmm0, (ARG_SIN_PTR) /* store sin(x) from xmm0[0] */ + shufps $1, %xmm0, %xmm0 /* move cos(x) to xmm0[0] */ + movss %xmm0, (ARG_COS_PTR) /* store cos(x) */ + ret + + .p2align 4 +L(sin_result_sin_poly): + /* + * Here if + * sin(x) = poly_sin * sign_sin + * cos(x) = poly_cos * sign_cos + */ + movsd (%r9,%rdx,8), %xmm4 /* 0|sign_cos */ + movhpd (%r9,%rcx,8), %xmm4 /* sign_sin|sign_cos */ + mulpd %xmm4, %xmm3 /* result_sin|result_cos */ + cvtpd2ps %xmm3, %xmm0 /* SP results */ + movss %xmm0, (ARG_COS_PTR) /* store cos(x) from xmm0[0] */ + shufps $1, %xmm0, %xmm0 /* move sin(x) to xmm0[0] */ + movss %xmm0, (ARG_SIN_PTR) /* store sin(x) */ + ret + + .p2align 4 +L(large_args): + /* Here if |x|>=9*Pi/4 */ + cmpl $0x7f800000, %eax /* x is Inf or NaN ? */ + jae L(arg_inf_or_nan) + + /* Here if finite |x|>=9*Pi/4 */ + cmpl $0x4b000000, %eax /* |x|<2^23 ? */ + jae L(very_large_args) + + /* Here if 9*Pi/4<=|x|<2^23 */ + movsd L(DP_INVPIO4)(%rip), %xmm1 /* 1/(Pi/4) */ + mulsd %xmm0, %xmm1 /* |x|/(Pi/4) */ + cvttsd2si %xmm1, %eax /* k=trunc(|x|/(Pi/4)) */ + addl $1, %eax /* k+1 */ + movl %eax, %edx + andl $0xfffffffe, %edx /* j=(k+1)&0xfffffffe */ + cvtsi2sdl %edx, %xmm4 /* DP j */ + movl %r8d, %ecx /* Load x */ + movsd L(DP_PIO4HI)(%rip), %xmm2 /* -PIO4HI = high part of -Pi/4 */ + shrl $29, %ecx /* (sign of x) << 2 */ + mulsd %xmm4, %xmm2 /* -j*PIO4HI */ + movsd L(DP_PIO4LO)(%rip), %xmm3 /* -PIO4LO = low part of -Pi/4 */ + addsd %xmm2, %xmm0 /* |x| - j*PIO4HI */ + mulsd %xmm3, %xmm4 /* j*PIO4LO */ + addsd %xmm4, %xmm0 /* t = |x| - j*PIO4HI - j*PIO4LO */ + jmp L(reconstruction) + + .p2align 4 +L(very_large_args): + /* Here if finite |x|>=2^23 */ + + /* bitpos = (ix>>23) - BIAS_32 + 59; */ + shrl $23, %eax /* eb = biased exponent of x */ + subl $68, %eax /* bitpos=eb-0x7f+59, where 0x7f */ + /*is exponent bias */ + movl $28, %ecx /* %cl=28 */ + movl %eax, %edx /* bitpos copy */ + + /* j = bitpos/28; */ + div %cl /* j in register %al=%ax/%cl */ + movapd %xmm0, %xmm3 /* |x| */ + andl $0xff, %eax /* clear unneeded remainder from %ah*/ + + imull $28, %eax, %ecx /* j*28 */ + lea L(_FPI)(%rip), %r9 + movsd L(DP_HI_MASK)(%rip), %xmm4 /* DP_HI_MASK */ + movapd %xmm0, %xmm5 /* |x| */ + mulsd -16(%r9,%rax,8), %xmm3 /* tmp3 = FPI[j-2]*|x| */ + movapd %xmm0, %xmm1 /* |x| */ + mulsd -8(%r9,%rax,8), %xmm5 /* tmp2 = FPI[j-1]*|x| */ + mulsd (%r9,%rax,8), %xmm0 /* tmp0 = FPI[j]*|x| */ + addl $19, %ecx /* j*28+19 */ + mulsd 8(%r9,%rax,8), %xmm1 /* tmp1 = FPI[j+1]*|x| */ + cmpl %ecx, %edx /* bitpos>=j*28+19 ? */ + jl L(very_large_skip1) + + /* Here if bitpos>=j*28+19 */ + andpd %xmm3, %xmm4 /* HI(tmp3) */ + subsd %xmm4, %xmm3 /* tmp3 = tmp3 - HI(tmp3) */ +L(very_large_skip1): + + movsd L(DP_2POW52)(%rip), %xmm6 + movapd %xmm5, %xmm2 /* tmp2 copy */ + addsd %xmm3, %xmm5 /* tmp5 = tmp3 + tmp2 */ + movl $1, %edx + addsd %xmm5, %xmm6 /* tmp6 = tmp5 + 2^52 */ + movsd 8+L(DP_2POW52)(%rip), %xmm4 + movd %xmm6, %eax /* k = I64_LO(tmp6); */ + addsd %xmm6, %xmm4 /* tmp4 = tmp6 - 2^52 */ + movl %r8d, %ecx /* Load x */ + comisd %xmm5, %xmm4 /* tmp4 > tmp5 ? */ + jbe L(very_large_skip2) + + /* Here if tmp4 > tmp5 */ + subl $1, %eax /* k-- */ + addsd 8+L(DP_ONES)(%rip), %xmm4 /* tmp4 -= 1.0 */ +L(very_large_skip2): + + andl %eax, %edx /* k&1 */ + lea L(DP_ZERONE)(%rip), %r9 + subsd %xmm4, %xmm3 /* tmp3 -= tmp4 */ + addsd (%r9,%rdx,8), %xmm3 /* t = DP_ZERONE[k&1] + tmp3 */ + addsd %xmm2, %xmm3 /* t += tmp2 */ + shrl $29, %ecx /* (sign of x) << 2 */ + addsd %xmm3, %xmm0 /* t += tmp0 */ + addl $1, %eax /* n=k+1 */ + addsd %xmm1, %xmm0 /* t += tmp1 */ + mulsd L(DP_PIO4)(%rip), %xmm0 /* t *= PI04 */ + + jmp L(reconstruction) /* end of very_large_args peth */ + + .p2align 4 +L(arg_less_pio4): + /* Here if |x|=9*Pi/4 */ @@ -262,7 +261,6 @@ L(very_large_skip2): jmp L(reconstruction) /* end of very_large_args peth */ - .p2align 4 L(arg_less_pio4): /* Here if |x|