This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Use fabs(f/l) rather than __fabs
- From: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- To: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>
- Cc: nd at arm dot com
- Date: Tue, 03 Oct 2017 16:49:18 +0100
- Subject: Re: [PATCH] Use fabs(f/l) rather than __fabs
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Szabolcs dot Nagy at arm dot com;
- Nodisclaimer: True
- References: <DB6PR0801MB2053B16BF79A3E6ECD6D7359837E0@DB6PR0801MB2053.eurprd08.prod.outlook.com> <59D39F92.302@arm.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
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.