This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Fix x86, x86_64 fmax, fmin sNaN handling, add tests (bug 20947) [committed]
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: libc-alpha at sourceware dot org
- Date: Fri, 16 Dec 2016 09:20:12 -0200
- Subject: Re: Fix x86, x86_64 fmax, fmin sNaN handling, add tests (bug 20947) [committed]
- Authentication-results: sourceware.org; auth=none
- References: <alpine.DEB.2.20.1612152352390.22439@digraph.polyomino.org.uk>
On 15/12/2016 21:53, Joseph Myers wrote:
> Various fmax and fmin function implementations mishandle sNaN
> arguments:
>
> (a) When both arguments are NaNs, the return value should be a qNaN,
> but sometimes it is an sNaN if at least one argument is an sNaN.
>
> (b) Under TS 18661-1 semantics, if either argument is an sNaN then the
> result should be a qNaN (whereas if one argument is a qNaN and the
> other is not a NaN, the result should be the non-NaN argument).
> Various implementations treat sNaNs like qNaNs here.
>
> This patch fixes the x86 and x86_64 versions (ignoring float and
> double for 32-bit x86 given the inability to reliably avoid the sNaN
> turning into a qNaN before it gets to the called function). Tests of
> sNaN inputs to these functions are added.
>
> Note on architecture versions I haven't changed for this issue:
> AArch64 already gets this right (it uses a hardware instruction with
> the correct semantics for both quiet and signaling NaNs) and does not
> need changes. It's possible Alpha, IA64, SPARC might need changes
> (this would be shown by the testsuite if so).
>
> Tested for x86_64 and x86 (both i686 and i586 builds, to cover the
> different x86 implementations). Committed.
I wonder if it with this recent changes on f{min,max} it is worth to
keep assembly implementations for the architectures that does not
provide a direct hardware instruction that get this right. I will
check on x86_64 and powercp64 if assembly one still performs better
than C code with a recent compiler and I think it is worth to check
on other architectures as well if it is the case