about summary refs log tree commit diff
path: root/sysdeps/libm-ieee754/s_llrintl.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/libm-ieee754/s_llrintl.c')
-rw-r--r--sysdeps/libm-ieee754/s_llrintl.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/sysdeps/libm-ieee754/s_llrintl.c b/sysdeps/libm-ieee754/s_llrintl.c
index 29fc3a300d..d3b9b12d76 100644
--- a/sysdeps/libm-ieee754/s_llrintl.c
+++ b/sysdeps/libm-ieee754/s_llrintl.c
@@ -34,7 +34,7 @@ long long int
 __llrintl (long double x)
 {
   int32_t se,j0;
-  u_int32_t i0, i1, i;
+  u_int32_t i0, i1;
   long long int result;
   volatile long double w;
   long double t;
@@ -45,23 +45,11 @@ __llrintl (long double x)
   sx = (se >> 15) & 1;
   j0 = (se & 0x7fff) - 0x3fff;
 
-  if (j0 < 31)
+  if (j0 < (int32_t) (8 * sizeof (long long int)))
     {
       if (j0 < -1)
 	return 0;
-      else
-	{
-	  w = two63[sx] + x;
-	  t = w - two63[sx];
-	  GET_LDOUBLE_WORDS (se, i0, i1, t);
-	  j0 = (se & 0x7fff) - 0x3fff;
-
-	  result = i0 >> (31 - j0);
-	}
-    }
-  else if (j0 < (int32_t) (8 * sizeof (long long int)))
-    {
-      if (j0 >= 63)
+      else if (j0 >= 63)
 	result = ((long long int) i0 << (j0 - 31)) | (i1 << (j0 - 63));
       else
 	{
@@ -70,7 +58,10 @@ __llrintl (long double x)
 	  GET_LDOUBLE_WORDS (se, i0, i1, t);
 	  j0 = (se & 0x7fff) - 0x3fff;
 
-	  result = ((long long int) i0 << (j0 - 31)) | (j >> (63 - j0));
+	  if (j0 < 31)
+	    result = i0 >> (31 - j0);
+	  else
+	    result = ((long long int) i0 << (j0 - 31)) | (i1 >> (63 - j0));
 	}
     }
   else