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] Use fabs(f/l) rather than __fabs


On 03/10/17 15:32, Szabolcs Nagy wrote:
> On 29/09/17 14:02, Wilco Dijkstra wrote:
>> diff --git a/sysdeps/ieee754/dbl-64/e_log10.c b/sysdeps/ieee754/dbl-64/e_log10.c
>> index dfb7d056caee5f592048559b448c899aa11e9de2..677cbc4df8739521c50a72d5ab657f438c74c129 100644
>> --- a/sysdeps/ieee754/dbl-64/e_log10.c
>> +++ b/sysdeps/ieee754/dbl-64/e_log10.c
>> @@ -65,7 +65,7 @@ __ieee754_log10 (double x)
>>    if (hx < 0x00100000)
>>      {                           /* x < 2**-1022  */
>>        if (__glibc_unlikely (((hx & 0x7fffffff) | lx) == 0))
>> -	return -two54 / __fabs (x);	/* log(+-0)=-inf  */
>> +	return -two54 / fabs (x);	/* log(+-0)=-inf  */
>>        if (__glibc_unlikely (hx < 0))
>>  	return (x - x) / (x - x);       /* log(-#) = NaN */
>>        k -= 54;
>> diff --git a/sysdeps/ieee754/dbl-64/e_log2.c b/sysdeps/ieee754/dbl-64/e_log2.c
>> index 2f3da129f83dd0dc2fc7da78cfce3804febdbac5..e4a6aff9a3b5aa68c03603bf4cb8bb78507ea9c6 100644
>> --- a/sysdeps/ieee754/dbl-64/e_log2.c
>> +++ b/sysdeps/ieee754/dbl-64/e_log2.c
>> @@ -83,7 +83,7 @@ __ieee754_log2 (double x)
>>    if (hx < 0x00100000)
>>      {                           /* x < 2**-1022  */
>>        if (__glibc_unlikely (((hx & 0x7fffffff) | lx) == 0))
>> -	return -two54 / __fabs (x);        /* log(+-0)=-inf */
>> +	return -two54 / fabs (x);        /* log(+-0)=-inf */
>>        if (__glibc_unlikely (hx < 0))
>>  	return (x - x) / (x - x);       /* log(-#) = NaN */
>>        k -= 54;
> 
> 
> note that on aarch64 wrong code is generated for these fabs
> changes, most likely a gcc bug, still investigating.
> 
> it is not visible on aarch64 because the compat wrapper
> handles the log(0) case, but without the wrapper (e.g. ilp32)
> log(0) in downward rounding becomes +inf instead of -inf,
> because fabs(x) is compiled to x-x for x==0 for some reason.
> 

sorry this analysis was wrong and has nothing to do with
the fabs change only the svid compat change matters.

it is a real bug in log2 and log10 of wordsize-64/
that is masked by the wrapper in the test system.


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