]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
MIPS: math-emu: Always propagate sNaN payload in quieting
authorMaciej W. Rozycki <macro@imgtec.com>
Fri, 13 Nov 2015 00:48:48 +0000 (00:48 +0000)
committerRalf Baechle <ralf@linux-mips.org>
Fri, 13 May 2016 12:02:11 +0000 (14:02 +0200)
Propagate sNaN payload in quieting in the legacy-NaN mode as well.  If
clearing the quiet bit would produce infinity, then set the next lower
trailing significand field bit, matching the SB-1 and BMIPS5000 hardware
implementations.  Some other MIPS FPU hardware implementations do
produce the default qNaN bit pattern instead.

This reverts some changes made for semantics preservation with commit
dc3ddf42 [MIPS: math-emu: Update sNaN quieting handlers], consequently
bringing back most of the semantics from before commit fdffbafb [Lots of
FPU bug fixes from Kjeld Borch Egevang.], except from the qNaN produced
in the infinity case.  Previously the default qNaN bit pattern was
produced in that case.

Signed-off-by: Maciej W. Rozycki <macro@imgtec.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Matthew Fortune <Matthew.Fortune@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/11483/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/math-emu/ieee754dp.c
arch/mips/math-emu/ieee754sp.c

index 47d26c805eac5b4f91d600eee67075ed980ab250..465a0342ed4c8ca8028420299ae374952870c63f 100644 (file)
@@ -54,10 +54,13 @@ union ieee754dp __cold ieee754dp_nanxcpt(union ieee754dp r)
        assert(ieee754dp_issnan(r));
 
        ieee754_setcx(IEEE754_INVALID_OPERATION);
-       if (ieee754_csr.nan2008)
+       if (ieee754_csr.nan2008) {
                DPMANT(r) |= DP_MBIT(DP_FBITS - 1);
-       else
-               r = ieee754dp_indef();
+       } else {
+               DPMANT(r) &= ~DP_MBIT(DP_FBITS - 1);
+               if (!ieee754dp_isnan(r))
+                       DPMANT(r) |= DP_MBIT(DP_FBITS - 2);
+       }
 
        return r;
 }
index e0b2c450b9634caadcd24d5a25d3f58d4ad2f805..860e9162097f4f285a86380e75088571bf07a9df 100644 (file)
@@ -54,10 +54,13 @@ union ieee754sp __cold ieee754sp_nanxcpt(union ieee754sp r)
        assert(ieee754sp_issnan(r));
 
        ieee754_setcx(IEEE754_INVALID_OPERATION);
-       if (ieee754_csr.nan2008)
+       if (ieee754_csr.nan2008) {
                SPMANT(r) |= SP_MBIT(SP_FBITS - 1);
-       else
-               r = ieee754sp_indef();
+       } else {
+               SPMANT(r) &= ~SP_MBIT(SP_FBITS - 1);
+               if (!ieee754sp_isnan(r))
+                       SPMANT(r) |= SP_MBIT(SP_FBITS - 2);
+       }
 
        return r;
 }