Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Feb 2019 08:46:07 +0000 (UTC)
From:      Peter Jeremy <peterj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r343953 - head/lib/msun/src
Message-ID:  <201902100846.x1A8k7vv056427@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: peterj
Date: Sun Feb 10 08:46:07 2019
New Revision: 343953
URL: https://svnweb.freebsd.org/changeset/base/343953

Log:
  Replace calls to sin(x) and cos(x) with a single call to sincos().
  Replace calls to sinf(x) and cosf(x) with a single call to sincosf().
  
  Submitted by:	Steve Kargl <sgk@troutmask.apl.washington.edu>
  Reviewed by:	bde
  Approved by:	grog
  MFC after:	3 days

Modified:
  head/lib/msun/src/e_j0.c
  head/lib/msun/src/e_j0f.c
  head/lib/msun/src/e_j1.c
  head/lib/msun/src/e_j1f.c
  head/lib/msun/src/e_jn.c

Modified: head/lib/msun/src/e_j0.c
==============================================================================
--- head/lib/msun/src/e_j0.c	Sun Feb 10 08:41:52 2019	(r343952)
+++ head/lib/msun/src/e_j0.c	Sun Feb 10 08:46:07 2019	(r343953)
@@ -93,8 +93,7 @@ __ieee754_j0(double x)
 	if(ix>=0x7ff00000) return one/(x*x);
 	x = fabs(x);
 	if(ix >= 0x40000000) {	/* |x| >= 2.0 */
-		s = sin(x);
-		c = cos(x);
+		sincos(x, &s, &c);
 		ss = s-c;
 		cc = s+c;
 		if(ix<0x7fe00000) {  /* Make sure x+x does not overflow. */
@@ -173,8 +172,7 @@ __ieee754_y0(double x)
          *              sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
          * to compute the worse one.
          */
-                s = sin(x);
-                c = cos(x);
+                sincos(x, &s, &c);
                 ss = s-c;
                 cc = s+c;
 	/*

Modified: head/lib/msun/src/e_j0f.c
==============================================================================
--- head/lib/msun/src/e_j0f.c	Sun Feb 10 08:41:52 2019	(r343952)
+++ head/lib/msun/src/e_j0f.c	Sun Feb 10 08:46:07 2019	(r343953)
@@ -55,8 +55,7 @@ __ieee754_j0f(float x)
 	if(ix>=0x7f800000) return one/(x*x);
 	x = fabsf(x);
 	if(ix >= 0x40000000) {	/* |x| >= 2.0 */
-		s = sinf(x);
-		c = cosf(x);
+		sincosf(x, &s, &c);
 		ss = s-c;
 		cc = s+c;
 		if(ix<0x7f000000) {  /* Make sure x+x does not overflow. */
@@ -128,8 +127,7 @@ __ieee754_y0f(float x)
          *              sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
          * to compute the worse one.
          */
-                s = sinf(x);
-                c = cosf(x);
+                sincosf(x, &s, &c);
                 ss = s-c;
                 cc = s+c;
 	/*

Modified: head/lib/msun/src/e_j1.c
==============================================================================
--- head/lib/msun/src/e_j1.c	Sun Feb 10 08:41:52 2019	(r343952)
+++ head/lib/msun/src/e_j1.c	Sun Feb 10 08:46:07 2019	(r343953)
@@ -94,8 +94,7 @@ __ieee754_j1(double x)
 	if(ix>=0x7ff00000) return one/x;
 	y = fabs(x);
 	if(ix >= 0x40000000) {	/* |x| >= 2.0 */
-		s = sin(y);
-		c = cos(y);
+		sincos(y, &s, &c);
 		ss = -s-c;
 		cc = s-c;
 		if(ix<0x7fe00000) {  /* make sure y+y not overflow */
@@ -159,8 +158,7 @@ __ieee754_y1(double x)
 	/* y1(x<0) = NaN and raise invalid exception. */
         if(hx<0) return vzero/vzero;
         if(ix >= 0x40000000) {  /* |x| >= 2.0 */
-                s = sin(x);
-                c = cos(x);
+                sincos(x, &s, &c);
                 ss = -s-c;
                 cc = s-c;
                 if(ix<0x7fe00000) {  /* make sure x+x not overflow */

Modified: head/lib/msun/src/e_j1f.c
==============================================================================
--- head/lib/msun/src/e_j1f.c	Sun Feb 10 08:41:52 2019	(r343952)
+++ head/lib/msun/src/e_j1f.c	Sun Feb 10 08:46:07 2019	(r343953)
@@ -56,8 +56,7 @@ __ieee754_j1f(float x)
 	if(ix>=0x7f800000) return one/x;
 	y = fabsf(x);
 	if(ix >= 0x40000000) {	/* |x| >= 2.0 */
-		s = sinf(y);
-		c = cosf(y);
+		sincosf(y, &s, &c);
 		ss = -s-c;
 		cc = s-c;
 		if(ix<0x7f000000) {  /* make sure y+y not overflow */
@@ -114,8 +113,7 @@ __ieee754_y1f(float x)
 	if(ix==0) return -one/vzero;
 	if(hx<0) return vzero/vzero;
         if(ix >= 0x40000000) {  /* |x| >= 2.0 */
-                s = sinf(x);
-                c = cosf(x);
+                sincosf(x, &s, &c);
                 ss = -s-c;
                 cc = s-c;
                 if(ix<0x7f000000) {  /* make sure x+x not overflow */

Modified: head/lib/msun/src/e_jn.c
==============================================================================
--- head/lib/msun/src/e_jn.c	Sun Feb 10 08:41:52 2019	(r343952)
+++ head/lib/msun/src/e_jn.c	Sun Feb 10 08:46:07 2019	(r343953)
@@ -54,7 +54,7 @@ double
 __ieee754_jn(int n, double x)
 {
 	int32_t i,hx,ix,lx, sgn;
-	double a, b, temp, di;
+	double a, b, c, s, temp, di;
 	double z, w;
 
     /* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x)
@@ -91,11 +91,12 @@ __ieee754_jn(int n, double x)
      *		   2	-s+c		-c-s
      *		   3	 s+c		 c-s
      */
+		sincos(x, &s, &c);
 		switch(n&3) {
-		    case 0: temp =  cos(x)+sin(x); break;
-		    case 1: temp = -cos(x)+sin(x); break;
-		    case 2: temp = -cos(x)-sin(x); break;
-		    case 3: temp =  cos(x)-sin(x); break;
+		    case 0: temp =  c+s; break;
+		    case 1: temp = -c+s; break;
+		    case 2: temp = -c-s; break;
+		    case 3: temp =  c-s; break;
 		}
 		b = invsqrtpi*temp/sqrt(x);
 	    } else {
@@ -216,7 +217,7 @@ __ieee754_yn(int n, double x)
 {
 	int32_t i,hx,ix,lx;
 	int32_t sign;
-	double a, b, temp;
+	double a, b, c, s, temp;
 
 	EXTRACT_WORDS(hx,lx,x);
 	ix = 0x7fffffff&hx;
@@ -248,11 +249,12 @@ __ieee754_yn(int n, double x)
      *		   2	-s+c		-c-s
      *		   3	 s+c		 c-s
      */
+		sincos(x, &s, &c);
 		switch(n&3) {
-		    case 0: temp =  sin(x)-cos(x); break;
-		    case 1: temp = -sin(x)-cos(x); break;
-		    case 2: temp = -sin(x)+cos(x); break;
-		    case 3: temp =  sin(x)+cos(x); break;
+		    case 0: temp =  s-c; break;
+		    case 1: temp = -s-c; break;
+		    case 2: temp = -s+c; break;
+		    case 3: temp =  s+c; break;
 		}
 		b = invsqrtpi*temp/sqrt(x);
 	} else {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902100846.x1A8k7vv056427>