a2cf7d
From d3833cb69c7ff42ac8df68ed7b646c98c3a32eb8 Mon Sep 17 00:00:00 2001
a2cf7d
From: Stefan Liebler <stli@linux.ibm.com>
a2cf7d
Date: Wed, 11 Dec 2019 15:09:16 +0100
a2cf7d
Subject: [PATCH 04/28] Always use wordsize-64 version of s_ceil.c.
a2cf7d
a2cf7d
This patch replaces s_ceil.c in sysdeps/dbl-64 with the one in
a2cf7d
sysdeps/dbl-64/wordsize-64 and removes the latter one.
a2cf7d
The code is not changed except changes in code style.
a2cf7d
a2cf7d
Also adjusted the include path in x86_64 and sparc64 files.
a2cf7d
a2cf7d
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
a2cf7d
(cherry picked from commit 9f234eafe8698fd9a441ca2309a299d0bd771156)
a2cf7d
---
a2cf7d
 sysdeps/ieee754/dbl-64/s_ceil.c               | 59 ++++++-------------
a2cf7d
 sysdeps/ieee754/dbl-64/wordsize-64/s_ceil.c   | 51 ----------------
a2cf7d
 .../sparc64/fpu/multiarch/s_ceil-generic.c    |  2 +-
a2cf7d
 .../sparc/sparc64/fpu/multiarch/s_ceil-vis3.c |  2 +-
a2cf7d
 sysdeps/x86_64/fpu/multiarch/s_ceil-c.c       |  2 +-
a2cf7d
 5 files changed, 21 insertions(+), 95 deletions(-)
a2cf7d
 delete mode 100644 sysdeps/ieee754/dbl-64/wordsize-64/s_ceil.c
a2cf7d
a2cf7d
diff --git a/sysdeps/ieee754/dbl-64/s_ceil.c b/sysdeps/ieee754/dbl-64/s_ceil.c
a2cf7d
index 5a7434c737..3becdfc515 100644
a2cf7d
--- a/sysdeps/ieee754/dbl-64/s_ceil.c
a2cf7d
+++ b/sysdeps/ieee754/dbl-64/s_ceil.c
a2cf7d
@@ -24,61 +24,38 @@
a2cf7d
 double
a2cf7d
 __ceil (double x)
a2cf7d
 {
a2cf7d
-  int32_t i0, i1, j0;
a2cf7d
-  uint32_t i, j;
a2cf7d
-  EXTRACT_WORDS (i0, i1, x);
a2cf7d
-  j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
a2cf7d
-  if (j0 < 20)
a2cf7d
+  int64_t i0, i;
a2cf7d
+  int32_t j0;
a2cf7d
+  EXTRACT_WORDS64 (i0, x);
a2cf7d
+  j0 = ((i0 >> 52) & 0x7ff) - 0x3ff;
a2cf7d
+  if (j0 <= 51)
a2cf7d
     {
a2cf7d
       if (j0 < 0)
a2cf7d
 	{
a2cf7d
-	  /* return 0*sign(x) if |x|<1 */
a2cf7d
+	  /* return 0 * sign(x) if |x| < 1  */
a2cf7d
 	  if (i0 < 0)
a2cf7d
-	    {
a2cf7d
-	      i0 = 0x80000000; i1 = 0;
a2cf7d
-	    }
a2cf7d
-	  else if ((i0 | i1) != 0)
a2cf7d
-	    {
a2cf7d
-	      i0 = 0x3ff00000; i1 = 0;
a2cf7d
-	    }
a2cf7d
+	    i0 = INT64_C (0x8000000000000000);
a2cf7d
+	  else if (i0 != 0)
a2cf7d
+	    i0 = INT64_C (0x3ff0000000000000);
a2cf7d
 	}
a2cf7d
       else
a2cf7d
 	{
a2cf7d
-	  i = (0x000fffff) >> j0;
a2cf7d
-	  if (((i0 & i) | i1) == 0)
a2cf7d
-	    return x;                        /* x is integral */
a2cf7d
+	  i = INT64_C (0x000fffffffffffff) >> j0;
a2cf7d
+	  if ((i0 & i) == 0)
a2cf7d
+	    return x;			/* x is integral  */
a2cf7d
 	  if (i0 > 0)
a2cf7d
-	    i0 += (0x00100000) >> j0;
a2cf7d
-	  i0 &= (~i); i1 = 0;
a2cf7d
+	    i0 += UINT64_C (0x0010000000000000) >> j0;
a2cf7d
+	  i0 &= ~i;
a2cf7d
 	}
a2cf7d
     }
a2cf7d
-  else if (j0 > 51)
a2cf7d
+  else
a2cf7d
     {
a2cf7d
       if (j0 == 0x400)
a2cf7d
-	return x + x;                   /* inf or NaN */
a2cf7d
+	return x + x;			/* inf or NaN  */
a2cf7d
       else
a2cf7d
-	return x;                       /* x is integral */
a2cf7d
-    }
a2cf7d
-  else
a2cf7d
-    {
a2cf7d
-      i = ((uint32_t) (0xffffffff)) >> (j0 - 20);
a2cf7d
-      if ((i1 & i) == 0)
a2cf7d
-	return x;                       /* x is integral */
a2cf7d
-      if (i0 > 0)
a2cf7d
-	{
a2cf7d
-	  if (j0 == 20)
a2cf7d
-	    i0 += 1;
a2cf7d
-	  else
a2cf7d
-	    {
a2cf7d
-	      j = i1 + (1 << (52 - j0));
a2cf7d
-	      if (j < i1)
a2cf7d
-		i0 += 1;                /* got a carry */
a2cf7d
-	      i1 = j;
a2cf7d
-	    }
a2cf7d
-	}
a2cf7d
-      i1 &= (~i);
a2cf7d
+	return x;			/* x is integral  */
a2cf7d
     }
a2cf7d
-  INSERT_WORDS (x, i0, i1);
a2cf7d
+  INSERT_WORDS64 (x, i0);
a2cf7d
   return x;
a2cf7d
 }
a2cf7d
 #ifndef __ceil
a2cf7d
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_ceil.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_ceil.c
a2cf7d
deleted file mode 100644
a2cf7d
index b99829d2b0..0000000000
a2cf7d
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_ceil.c
a2cf7d
+++ /dev/null
a2cf7d
@@ -1,51 +0,0 @@
a2cf7d
-/* @(#)s_ceil.c 5.1 93/09/24 */
a2cf7d
-/*
a2cf7d
- * ====================================================
a2cf7d
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
a2cf7d
- *
a2cf7d
- * Developed at SunPro, a Sun Microsystems, Inc. business.
a2cf7d
- * Permission to use, copy, modify, and distribute this
a2cf7d
- * software is freely granted, provided that this notice
a2cf7d
- * is preserved.
a2cf7d
- * ====================================================
a2cf7d
- */
a2cf7d
-
a2cf7d
-/*
a2cf7d
- * ceil(x)
a2cf7d
- * Return x rounded toward -inf to integral value
a2cf7d
- * Method:
a2cf7d
- *	Bit twiddling.
a2cf7d
- */
a2cf7d
-
a2cf7d
-#include <math.h>
a2cf7d
-#include <math_private.h>
a2cf7d
-#include <libm-alias-double.h>
a2cf7d
-
a2cf7d
-double
a2cf7d
-__ceil(double x)
a2cf7d
-{
a2cf7d
-	int64_t i0,i;
a2cf7d
-	int32_t j0;
a2cf7d
-	EXTRACT_WORDS64(i0,x);
a2cf7d
-	j0 = ((i0>>52)&0x7ff)-0x3ff;
a2cf7d
-	if(j0<=51) {
a2cf7d
-	    if(j0<0) {
a2cf7d
-	      /* return 0*sign(x) if |x|<1 */
a2cf7d
-	      if(i0<0) {i0=INT64_C(0x8000000000000000);}
a2cf7d
-	      else if(i0!=0) { i0=INT64_C(0x3ff0000000000000);}
a2cf7d
-	    } else {
a2cf7d
-		i = INT64_C(0x000fffffffffffff)>>j0;
a2cf7d
-		if((i0&i)==0) return x; /* x is integral */
a2cf7d
-		if(i0>0) i0 += UINT64_C(0x0010000000000000)>>j0;
a2cf7d
-		i0 &= (~i);
a2cf7d
-	    }
a2cf7d
-	} else {
a2cf7d
-	    if(j0==0x400) return x+x;	/* inf or NaN */
a2cf7d
-	    else return x;		/* x is integral */
a2cf7d
-	}
a2cf7d
-	INSERT_WORDS64(x,i0);
a2cf7d
-	return x;
a2cf7d
-}
a2cf7d
-#ifndef __ceil
a2cf7d
-libm_alias_double (__ceil, ceil)
a2cf7d
-#endif
a2cf7d
diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_ceil-generic.c b/sysdeps/sparc/sparc64/fpu/multiarch/s_ceil-generic.c
a2cf7d
index febea745e1..80f68b6766 100644
a2cf7d
--- a/sysdeps/sparc/sparc64/fpu/multiarch/s_ceil-generic.c
a2cf7d
+++ b/sysdeps/sparc/sparc64/fpu/multiarch/s_ceil-generic.c
a2cf7d
@@ -1,2 +1,2 @@
a2cf7d
 #define __ceil __ceil_generic
a2cf7d
-#include <sysdeps/ieee754/dbl-64/wordsize-64/s_ceil.c>
a2cf7d
+#include <sysdeps/ieee754/dbl-64/s_ceil.c>
a2cf7d
diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_ceil-vis3.c b/sysdeps/sparc/sparc64/fpu/multiarch/s_ceil-vis3.c
a2cf7d
index a03a0090f0..59822e0f8c 100644
a2cf7d
--- a/sysdeps/sparc/sparc64/fpu/multiarch/s_ceil-vis3.c
a2cf7d
+++ b/sysdeps/sparc/sparc64/fpu/multiarch/s_ceil-vis3.c
a2cf7d
@@ -20,4 +20,4 @@
a2cf7d
 
a2cf7d
 #define __ceil __ceil_vis3
a2cf7d
 
a2cf7d
-#include <sysdeps/ieee754/dbl-64/wordsize-64/s_ceil.c>
a2cf7d
+#include <sysdeps/ieee754/dbl-64/s_ceil.c>
a2cf7d
diff --git a/sysdeps/x86_64/fpu/multiarch/s_ceil-c.c b/sysdeps/x86_64/fpu/multiarch/s_ceil-c.c
a2cf7d
index 6a5ea3ff27..ada28baa1a 100644
a2cf7d
--- a/sysdeps/x86_64/fpu/multiarch/s_ceil-c.c
a2cf7d
+++ b/sysdeps/x86_64/fpu/multiarch/s_ceil-c.c
a2cf7d
@@ -1,2 +1,2 @@
a2cf7d
 #define __ceil __ceil_c
a2cf7d
-#include <sysdeps/ieee754/dbl-64/wordsize-64/s_ceil.c>
a2cf7d
+#include <sysdeps/ieee754/dbl-64/s_ceil.c>
a2cf7d
-- 
a2cf7d
2.18.2
a2cf7d