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]

Re: [PATCH] Fix for logb/logbf/logbl (bz 13954/13955/13956)


Adhemerval Zanella <azanella@linux.vnet.ibm.com> writes:

> On 05/25/2012 01:20 PM, Adhemerval Zanella wrote:
>> On 05/25/2012 09:56 AM, Andreas Schwab wrote:
>>
>> diff --git a/sysdeps/ieee754/ldbl-128ibm/s_logbl.c b/sysdeps/ieee754/ldbl-128ibm/s_logbl.c
>> index 678b6ca..9b0bd98 100644
>> --- a/sysdeps/ieee754/ldbl-128ibm/s_logbl.c
>> +++ b/sysdeps/ieee754/ldbl-128ibm/s_logbl.c
>> @@ -38,10 +38,12 @@ __logbl (long double x)
>>      {
>>        /* POSIX specifies that denormal number is treated as
>>           though it were normalized.  */
>> -      int m1 = (hx == 0) ? 0 : __builtin_clzll (hx);
>> -      int m2 = (lx == 0) ? 0 : __builtin_clzll (lx);
>> -      int ma = (m1 == 0) ? m2 + 64 : m1;
>> -      return -1022.0 + (long double)(11 - ma);
>> +      int ma;
>> +      if (hx == 0)
>> +	ma = __builtin_clzll (lx) + 64;
>> +      else
>> +	ma = __builtin_clzll (hx);
>> +      rhx -= ma - 12;
>>      }
>>    return (long double) (rhx - 1023);
>>  }
>>
> Based on your previous email I think only 'hx' should be considered as:
>
> +      int ma = (hx == 0) ? 0 : __builtin_clzll (hx);
> +      rhx -= ma - 12;

I think then the zero check at the top also only needs to look at hx:

diff --git a/sysdeps/ieee754/ldbl-128ibm/s_logbl.c b/sysdeps/ieee754/ldbl-128ibm/s_logbl.c
index 678b6ca..92ce2c1 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_logbl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_logbl.c
@@ -30,7 +30,7 @@ __logbl (long double x)
 
   GET_LDOUBLE_WORDS64 (hx, lx, x);
   hx &= 0x7fffffffffffffffLL;	/* high |x| */
-  if ((hx | (lx & 0x7fffffffffffffffLL)) == 0)
+  if (hx == 0)
     return -1.0 / fabs (x);
   if (hx >= 0x7ff0000000000000LL)
     return x * x;
@@ -38,10 +38,7 @@ __logbl (long double x)
     {
       /* POSIX specifies that denormal number is treated as
          though it were normalized.  */
-      int m1 = (hx == 0) ? 0 : __builtin_clzll (hx);
-      int m2 = (lx == 0) ? 0 : __builtin_clzll (lx);
-      int ma = (m1 == 0) ? m2 + 64 : m1;
-      return -1022.0 + (long double)(11 - ma);
+      rhx -= __builtin_clzll (hx) - 12;
     }
   return (long double) (rhx - 1023);
 }

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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