Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 May 2019 22:56:50 +0000 (UTC)
From:      Peter Jeremy <peterj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r347068 - stable/11/lib/msun/src
Message-ID:  <201905032256.x43MuofS040524@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: peterj
Date: Fri May  3 22:56:50 2019
New Revision: 347068
URL: https://svnweb.freebsd.org/changeset/base/347068

Log:
  MFC r343953:
  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().
  
  Approved by:	grog, jhb (mentors)

Modified:
  stable/11/lib/msun/src/e_j0.c
  stable/11/lib/msun/src/e_j0f.c
  stable/11/lib/msun/src/e_j1.c
  stable/11/lib/msun/src/e_j1f.c
  stable/11/lib/msun/src/e_jn.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/msun/src/e_j0.c
==============================================================================
--- stable/11/lib/msun/src/e_j0.c	Fri May  3 22:54:56 2019	(r347067)
+++ stable/11/lib/msun/src/e_j0.c	Fri May  3 22:56:50 2019	(r347068)
@@ -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: stable/11/lib/msun/src/e_j0f.c
==============================================================================
--- stable/11/lib/msun/src/e_j0f.c	Fri May  3 22:54:56 2019	(r347067)
+++ stable/11/lib/msun/src/e_j0f.c	Fri May  3 22:56:50 2019	(r347068)
@@ -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: stable/11/lib/msun/src/e_j1.c
==============================================================================
--- stable/11/lib/msun/src/e_j1.c	Fri May  3 22:54:56 2019	(r347067)
+++ stable/11/lib/msun/src/e_j1.c	Fri May  3 22:56:50 2019	(r347068)
@@ -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: stable/11/lib/msun/src/e_j1f.c
==============================================================================
--- stable/11/lib/msun/src/e_j1f.c	Fri May  3 22:54:56 2019	(r347067)
+++ stable/11/lib/msun/src/e_j1f.c	Fri May  3 22:56:50 2019	(r347068)
@@ -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: stable/11/lib/msun/src/e_jn.c
==============================================================================
--- stable/11/lib/msun/src/e_jn.c	Fri May  3 22:54:56 2019	(r347067)
+++ stable/11/lib/msun/src/e_jn.c	Fri May  3 22:56:50 2019	(r347068)
@@ -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?201905032256.x43MuofS040524>