This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Remove redundant gotos


Hi,

The goto lines in __sin and __cos are redundant since the regular
program flow would in fact take control to 'ret'.  This patch removes
them.  Verified on x86_64 that the generated code is identical.

Siddhesh

	* sysdeps/ieee754/dbl-64/s_sin.c (__sin): Remove redundant
	gotos.
	(__cos): Likewise.

diff --git a/sysdeps/ieee754/dbl-64/s_sin.c b/sysdeps/ieee754/dbl-64/s_sin.c
index c514a0a..09b55b4 100644
--- a/sysdeps/ieee754/dbl-64/s_sin.c
+++ b/sysdeps/ieee754/dbl-64/s_sin.c
@@ -143,10 +143,7 @@ __sin (double x)
   m = u.i[HIGH_HALF];
   k = 0x7fffffff & m;		/* no sign           */
   if (k < 0x3e500000)		/* if x->0 =>sin(x)=x */
-    {
-      retval = x;
-      goto ret;
-    }
+    retval = x;
  /*---------------------------- 2^-26 < |x|< 0.25 ----------------------*/
   else if (k < 0x3fd00000)
     {
@@ -156,7 +153,6 @@ __sin (double x)
       res = x + t;
       cor = (x - res) + t;
       retval = (res == res + 1.07 * cor) ? res : slow (x);
-      goto ret;
     }				/*  else  if (k < 0x3fd00000)    */
 /*---------------------------- 0.25<|x|< 0.855469---------------------- */
   else if (k < 0x3feb6000)
@@ -175,7 +171,6 @@ __sin (double x)
       res = sn + cor;
       cor = (sn - res) + cor;
       retval = (res == res + 1.096 * cor) ? res : slow1 (x);
-      goto ret;
     }				/*   else  if (k < 0x3feb6000)    */
 
 /*----------------------- 0.855469  <|x|<2.426265  ----------------------*/
@@ -205,7 +200,6 @@ __sin (double x)
       res = cs + cor;
       cor = (cs - res) + cor;
       retval = (res == res + 1.020 * cor) ? ((m > 0) ? res : -res) : slow2 (x);
-      goto ret;
     }				/*   else  if (k < 0x400368fd)    */
 
 /*-------------------------- 2.426265<|x|< 105414350 ----------------------*/
@@ -237,7 +231,6 @@ __sin (double x)
 	      res = TAYLOR_SINCOS (xx, a, da, cor);
 	      cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
 	      retval = (res == res + cor) ? res : sloww (a, da, x);
-	      goto ret;
 	    }
 	  else
 	    {
@@ -269,7 +262,6 @@ __sin (double x)
 	      cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
 	      retval = ((res == res + cor) ? ((m) ? res : -res)
 			: sloww1 (a, da, x));
-	      goto ret;
 	    }
 	  break;
 
@@ -296,11 +288,8 @@ __sin (double x)
 	  cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
 	  retval = ((res == res + cor) ? ((n & 2) ? -res : res)
 		    : sloww2 (a, da, x, n));
-	  goto ret;
-
 	  break;
 	}
-
     }				/*   else  if (k <  0x419921FB )    */
 
 /*---------------------105414350 <|x|< 281474976710656 --------------------*/
@@ -337,7 +326,6 @@ __sin (double x)
 	      res = TAYLOR_SINCOS (xx, a, da, cor);
 	      cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
 	      retval = (res == res + cor) ? res : bsloww (a, da, x, n);
-	      goto ret;
 	    }
 	  else
 	    {
@@ -369,7 +357,6 @@ __sin (double x)
 	      cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
 	      retval = ((res == res + cor) ? ((m) ? res : -res)
 			: bsloww1 (a, da, x, n));
-	      goto ret;
 	    }
 	  break;
 
@@ -396,8 +383,6 @@ __sin (double x)
 	  cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
 	  retval = ((res == res + cor) ? ((n & 2) ? -res : res)
 		    : bsloww2 (a, da, x, n));
-	  goto ret;
-
 	  break;
 	}
     }				/*   else  if (k <  0x42F00000 )   */
@@ -413,20 +398,17 @@ __sin (double x)
 	    retval = bsloww (a, da, x, n);
 	  else
 	    retval = bsloww1 (a, da, x, n);
-	  goto ret;
 	  break;
 	case 2:
 	  if (a * a < 0.01588)
 	    retval = bsloww (-a, -da, x, n);
 	  else
 	    retval = bsloww1 (-a, -da, x, n);
-	  goto ret;
 	  break;
 
 	case 1:
 	case 3:
 	  retval = bsloww2 (a, da, x, n);
-	  goto ret;
 	  break;
 	}
     }				/*   else  if (k <  0x7ff00000 )    */
@@ -437,10 +419,8 @@ __sin (double x)
       if (k == 0x7ff00000 && u.i[LOW_HALF] == 0)
 	__set_errno (EDOM);
       retval = x / x;
-      goto ret;
     }
 
-ret:
   return retval;
 }
 
@@ -467,11 +447,9 @@ __cos (double x)
   m = u.i[HIGH_HALF];
   k = 0x7fffffff & m;
 
+  /* |x|<2^-27 => cos(x)=1 */
   if (k < 0x3e400000)
-    {
-      retval = 1.0;
-      goto ret;
-    }				/* |x|<2^-27 => cos(x)=1 */
+    retval = 1.0;
 
   else if (k < 0x3feb6000)
     {				/* 2^-27 < |x| < 0.855469 */
@@ -490,7 +468,6 @@ __cos (double x)
       res = cs + cor;
       cor = (cs - res) + cor;
       retval = (res == res + 1.020 * cor) ? res : cslow2 (x);
-      goto ret;
     }				/*   else  if (k < 0x3feb6000)    */
 
   else if (k < 0x400368fd)
@@ -504,7 +481,6 @@ __cos (double x)
 	  res = TAYLOR_SINCOS (xx, a, da, cor);
 	  cor = (cor > 0) ? 1.02 * cor + 1.0e-31 : 1.02 * cor - 1.0e-31;
 	  retval = (res == res + cor) ? res : csloww (a, da, x);
-	  goto ret;
 	}
       else
 	{
@@ -536,7 +512,6 @@ __cos (double x)
 	  cor = (cor > 0) ? 1.035 * cor + 1.0e-31 : 1.035 * cor - 1.0e-31;
 	  retval = ((res == res + cor) ? ((m) ? res : -res)
 		    : csloww1 (a, da, x));
-	  goto ret;
 	}
 
     }				/*   else  if (k < 0x400368fd)    */
@@ -569,7 +544,6 @@ __cos (double x)
 	      res = TAYLOR_SINCOS (xx, a, da, cor);
 	      cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
 	      retval = (res == res + cor) ? res : csloww (a, da, x);
-	      goto ret;
 	    }
 	  else
 	    {
@@ -601,7 +575,6 @@ __cos (double x)
 	      cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
 	      retval = ((res == res + cor) ? ((m) ? res : -res)
 			: csloww1 (a, da, x));
-	      goto ret;
 	    }
 	  break;
 
@@ -628,8 +601,6 @@ __cos (double x)
 	  cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
 	  retval = ((res == res + cor) ? ((n) ? -res : res)
 		    : csloww2 (a, da, x, n));
-	  goto ret;
-
 	  break;
 	}
     }				/*   else  if (k <  0x419921FB )    */
@@ -666,7 +637,6 @@ __cos (double x)
 	      res = TAYLOR_SINCOS (xx, a, da, cor);
 	      cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
 	      retval = (res == res + cor) ? res : bsloww (a, da, x, n);
-	      goto ret;
 	    }
 	  else
 	    {
@@ -698,7 +668,6 @@ __cos (double x)
 	      cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
 	      retval = ((res == res + cor) ? ((m) ? res : -res)
 			: bsloww1 (a, da, x, n));
-	      goto ret;
 	    }
 	  break;
 
@@ -725,7 +694,6 @@ __cos (double x)
 	  cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
 	  retval = ((res == res + cor) ? ((n) ? -res : res)
 		    : bsloww2 (a, da, x, n));
-	  goto ret;
 	  break;
 	}
     }				/*   else  if (k <  0x42F00000 )    */
@@ -741,20 +709,17 @@ __cos (double x)
 	    retval = bsloww (-a, -da, x, n);
 	  else
 	    retval = bsloww1 (-a, -da, x, n);
-	  goto ret;
 	  break;
 	case 3:
 	  if (a * a < 0.01588)
 	    retval = bsloww (a, da, x, n);
 	  else
 	    retval = bsloww1 (a, da, x, n);
-	  goto ret;
 	  break;
 
 	case 0:
 	case 2:
 	  retval = bsloww2 (a, da, x, n);
-	  goto ret;
 	  break;
 	}
     }				/*   else  if (k <  0x7ff00000 )    */
@@ -764,10 +729,8 @@ __cos (double x)
       if (k == 0x7ff00000 && u.i[LOW_HALF] == 0)
 	__set_errno (EDOM);
       retval = x / x;		/* |x| > 2^1024 */
-      goto ret;
     }
 
-ret:
   return retval;
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]