[PATCHv4] ldbl-128: Use L(x) macro for long double constants

Message ID 0d7ac509-f338-fa7c-9cbd-2e0f5d845788@linux.vnet.ibm.com
State Committed
Headers

Commit Message

Paul E. Murphy Sept. 13, 2016, 3:42 p.m. UTC
  On 09/09/2016 09:14 AM, Joseph Myers wrote:
> On Thu, 8 Sep 2016, Paul E. Murphy wrote:
> 
>> On 09/08/2016 05:56 PM, Joseph Myers wrote:
>>> On Fri, 2 Sep 2016, Paul E. Murphy wrote:
>>>
>>>> @@ -65,7 +65,7 @@ __ieee754_atan2l(_Float128 y, _Float128 x)
>>>>  	if(((ix|((lx|-lx)>>63))>0x7fff000000000000LL)||
>>>>  	   ((iy|((ly|-ly)>>63))>0x7fff000000000000LL))	/* x or y is NaN */
>>>>  	   return x+y;
>>>> -	if(((hx-0x3fff000000000000LL)|lx)==0) return __atanl(y);   /* x=1.0L */
>>>> +	if(((hx-0x3fff000000000000LL)|lx)==0) return __atanl(y);   /* x=1 */
>>>
>>> Is this change of a comment deliberate?  I thought you were avoiding 
>>> changing comments.
>>
>> This is a limitation of the conversion script.  It only skips lines
>> which start with a /* comment.  This can be reverted via the fixup,
>> patch or I can note the limitation in the commit message.
> 
> The patch is OK with the comment change reverted.
> 

I'll commit with the updated messages:

    ldbl-128: Use L(x) macro for long double constants
    
    This runs the attached sed script against these files using
    a regex which aggressively matches long double literals
    when not obviously part of a comment.
    
    Likewise, 5 digit or less integral constants are replaced
    with integral constants, excepting the two cases of 0 used
    in large tables, which are also the only integral values
    of the form x.0*E0L encountered within these converted
    files.
    
    Likewise, -L(x) is transformed into L(-x).
    
    Naturally, the script has a few minor hiccups which are
    more clearly remedied via the attached fixup patch.  Such
    hiccups include, context-sensitive promotion to a real
    type, and munging constants inside harder to detect
    comment blocks.
    
    	* sysdeps/ieee754/ldbl-128/e_acoshl.c: Wrap long double literals
    	with L() and remove explicit suffix, convert real literals
    	which can be equivalentally substituted with integers, and
    	transform -L(x) to L(-x).
    
    	* sysdeps/ieee754/ldbl-128/e_acosl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_asinl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_atan2l.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_atanhl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_coshl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_exp10l.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_expl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_gammal_r.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_hypotl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_j0l.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_j1l.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_jnl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_lgammal_r.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_log10l.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_log2l.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_logl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_powl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_rem_pio2l.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_remainderl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/e_sinhl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/k_cosl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/k_sincosl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/k_sinl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/k_tanl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/lgamma_negl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_asinhl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_atanl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_cbrtl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_cosl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_erfl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_expm1l.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_fmal.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_frexpl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_llrintl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_llroundl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_log1pl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_lrintl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_lroundl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_nearbyintl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_nextafterl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_remquol.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_scalblnl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_scalbnl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_sincosl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_sinl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_tanhl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/s_tanl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/t_expl.h: Likewise.
    	* sysdeps/ieee754/ldbl-128/t_sincosl.c: Likewise.
    	* sysdeps/ieee754/ldbl-128/x2y2m1l.c: Likewise.

With the updated fixup patch to revert the 1.0L -> 1 change in noted
comment of e_atan2l.c. The script remains unchanged.
  

Comments

Paul E. Murphy Sept. 13, 2016, 8:43 p.m. UTC | #1
Committed as 02bbfb4.
  

Patch

diff --git a/sysdeps/ieee754/ldbl-128/e_atan2l.c b/sysdeps/ieee754/ldbl-128/e_atan2l.c
index d51a971..faecd1a 100644
--- a/sysdeps/ieee754/ldbl-128/e_atan2l.c
+++ b/sysdeps/ieee754/ldbl-128/e_atan2l.c
@@ -65,7 +65,7 @@  __ieee754_atan2l(_Float128 y, _Float128 x)
 	if(((ix|((lx|-lx)>>63))>0x7fff000000000000LL)||
 	   ((iy|((ly|-ly)>>63))>0x7fff000000000000LL))	/* x or y is NaN */
 	   return x+y;
-	if(((hx-0x3fff000000000000LL)|lx)==0) return __atanl(y);   /* x=1 */
+	if(((hx-0x3fff000000000000LL)|lx)==0) return __atanl(y);   /* x=1.0L */
 	m = ((hy>>63)&1)|((hx>>62)&2);	/* 2*sign(x)+sign(y) */
 
     /* when y = 0 */
diff --git a/sysdeps/ieee754/ldbl-128/e_exp10l.c b/sysdeps/ieee754/ldbl-128/e_exp10l.c
index 9a2c8b8..9432b18 100644
--- a/sysdeps/ieee754/ldbl-128/e_exp10l.c
+++ b/sysdeps/ieee754/ldbl-128/e_exp10l.c
@@ -39,7 +39,7 @@  __ieee754_exp10l (_Float128 arg)
     return 1;
 
   u.value = arg;
-  u.parts64sw &= 0xfe00000000000000LL;
+  u.parts64.lsw &= 0xfe00000000000000LL;
   arg_high = u.value;
   arg_low = arg - arg_high;
   exp_high = arg_high * log10_high;
diff --git a/sysdeps/ieee754/ldbl-128/e_jnl.c b/sysdeps/ieee754/ldbl-128/e_jnl.c
index 1f80b00..470631e 100644
--- a/sysdeps/ieee754/ldbl-128/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-128/e_jnl.c
@@ -328,7 +328,7 @@  __ieee754_ynl (int n, _Float128 x)
   if (x <= 0)
     {
       if (x == 0)
-	return ((n < 0 && (n & 1) != 0) ? 1 : -1) / 0;
+	return ((n < 0 && (n & 1) != 0) ? 1 : -1) / L(0.0);
       if (se & 0x80000000)
 	return zero / (zero * x);
     }
diff --git a/sysdeps/ieee754/ldbl-128/lgamma_negl.c b/sysdeps/ieee754/ldbl-128/lgamma_negl.c
index 601d8f8..0969dcc 100644
--- a/sysdeps/ieee754/ldbl-128/lgamma_negl.c
+++ b/sysdeps/ieee754/ldbl-128/lgamma_negl.c
@@ -450,7 +450,7 @@  __lgamma_negl (_Float128 x, int *signgamp)
      integers and determine the sign of the result.  */
   int i = __floorl (-2 * x);
   if ((i & 1) == 0 && i == -2 * x)
-    return 1 / 0;
+    return L(1.0) / L(0.0);
   _Float128 xn = ((i & 1) == 0 ? -i / 2 : (-i - 1) / 2);
   i -= 4;
   *signgamp = ((i & 2) == 0 ? -1 : 1);
diff --git a/sysdeps/ieee754/ldbl-128/s_fmal.c b/sysdeps/ieee754/ldbl-128/s_fmal.c
index 7b12441..eb1e27e 100644
--- a/sysdeps/ieee754/ldbl-128/s_fmal.c
+++ b/sysdeps/ieee754/ldbl-128/s_fmal.c
@@ -261,10 +261,10 @@  __fmal (_Float128 x, _Float128 y, _Float128 z)
       if (v.ieee.exponent > 228)
 	return (a1 + u.d) * L(0x1p-228);
       /* If v.d * 0x1p-228L with round to zero is a subnormal above
-	 or equal to LDBL_MIN / 2, then v.d * L(0x1p-228) shifts mantissa
+	 or equal to LDBL_MIN / 2, then v.d * 0x1p-228L shifts mantissa
 	 down just by 1 bit, which means v.ieee.mantissa3 |= j would
 	 change the round bit, not sticky or guard bit.
-	 v.d * L(0x1p-228) never normalizes by shifting up,
+	 v.d * 0x1p-228L never normalizes by shifting up,
 	 so round bit plus sticky bit should be already enough
 	 for proper rounding.  */
       if (v.ieee.exponent == 228)