This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: Make MIPS soft-fp preserve NaN payloads for NAN2008
- From: "Maciej W. Rozycki" <macro at linux-mips dot org>
- To: Matthew Fortune <Matthew dot Fortune at imgtec dot com>
- Cc: Joseph Myers <joseph at codesourcery dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "clm at codesourcery dot com" <clm at codesourcery dot com>, "Maciej W. Rozycki" <macro at imgtec dot com>
- Date: Wed, 4 Jan 2017 12:54:50 +0000 (GMT)
- Subject: RE: Make MIPS soft-fp preserve NaN payloads for NAN2008
- Authentication-results: sourceware.org; auth=none
- References: <alpine.DEB.2.20.1701022006120.24470@digraph.polyomino.org.uk> <6D39441BF12EF246A7ABCE6654B0235380B127A8@HHMAIL01.hh.imgtec.org>
On Wed, 4 Jan 2017, Matthew Fortune wrote:
> > The MIPS sfp-machine.h has an _FP_CHOOSENAN implementation which
> > emulates hardware semantics of not preserving signaling NaN payloads for
> > an operation with two NaN arguments (although that doesn't suffice to
> > avoid sNaN payload preservation in any case with just one NaN argument).
> >
> > However, those are only hardware semantics in the legacy NaN case; in
> > the NAN2008 case, the architecture documentation says hardware preserves
> > payloads in such cases. Furthermore, this implementation assumes legacy
> > NaN semantics, so in the NAN2008 case the implementation actually has
> > the effect of preserving sNaN payloads but not preserving qNaN payloads,
> > when both should be preserved.
> >
> > This patch fixes the code just to copy from the first argument (at the
> > level of libgcc, it's not meaningful which argument is the first and
> > which is the second).
> >
> > Tested for mips64-linux-gnu (soft float, NAN2008) with the glibc math/
> > tests. OK to commit?
> >
> > 2017-01-02 Joseph Myers <joseph@codesourcery.com>
> >
> > * config/mips/sfp-machine.h (_FP_CHOOSENAN): Always preserve NaN
> > payload if [__mips_nan2008].
>
> Thanks for finding and fixing this.
>
> OK to commit.
AFAIR we deliberately decided not to define a 2008-NaN soft-float ABI,
and chose to require all soft-float binaries to use the legacy encoding.
The implementation of all toolchain pieces reflects this, although
perhaps the case of passing `-mnan=2008 -msoft-float' to GCC (also keeping
in mind a `--with-nan=2008' default) has been missed and is not handled
correctly, either by refusing compilation or by staying with the legacy
NaN encoding. GAS might need some tweaks here too.
FWIW,
Maciej