Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: math-emu: Don't pass qNaNs through quieting handlers

Don't call the `ieee754sp_nanxcpt' and `ieee754dp_nanxcpt' sNaN quieting
handlers for a qNaN supplied to floating-point format conversions or
SQRT.S/SQRT.D instructions, or for a qNaN produced out of a negative
operand supplied to SQRT.S/SQRT.D instructions. Return the qNaN right
away in these cases.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/9687/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Maciej W. Rozycki and committed by
Ralf Baechle
539bfb57 d19cf86e

+8 -8
+1 -1
arch/mips/math-emu/dp_fsp.c
··· 44 44 return ieee754dp_nanxcpt(ieee754dp_indef()); 45 45 46 46 case IEEE754_CLASS_QNAN: 47 - return ieee754dp_nanxcpt(ieee754dp_nan_fsp(xs, xm)); 47 + return ieee754dp_nan_fsp(xs, xm); 48 48 49 49 case IEEE754_CLASS_INF: 50 50 return ieee754dp_inf(xs);
+3 -3
arch/mips/math-emu/dp_sqrt.c
··· 44 44 switch (xc) { 45 45 case IEEE754_CLASS_QNAN: 46 46 /* sqrt(Nan) = Nan */ 47 - return ieee754dp_nanxcpt(x); 47 + return x; 48 48 49 49 case IEEE754_CLASS_SNAN: 50 50 ieee754_setcx(IEEE754_INVALID_OPERATION); ··· 58 58 if (xs) { 59 59 /* sqrt(-Inf) = Nan */ 60 60 ieee754_setcx(IEEE754_INVALID_OPERATION); 61 - return ieee754dp_nanxcpt(ieee754dp_indef()); 61 + return ieee754dp_indef(); 62 62 } 63 63 /* sqrt(+Inf) = Inf */ 64 64 return x; ··· 71 71 if (xs) { 72 72 /* sqrt(-x) = Nan */ 73 73 ieee754_setcx(IEEE754_INVALID_OPERATION); 74 - return ieee754dp_nanxcpt(ieee754dp_indef()); 74 + return ieee754dp_indef(); 75 75 } 76 76 break; 77 77 }
+1 -1
arch/mips/math-emu/sp_fdp.c
··· 50 50 nan = ieee754sp_nan_fdp(xs, xm); 51 51 if (!ieee754sp_isnan(nan)) 52 52 nan = ieee754sp_indef(); 53 - return ieee754sp_nanxcpt(nan); 53 + return nan; 54 54 55 55 case IEEE754_CLASS_INF: 56 56 return ieee754sp_inf(xs);
+3 -3
arch/mips/math-emu/sp_sqrt.c
··· 37 37 switch (xc) { 38 38 case IEEE754_CLASS_QNAN: 39 39 /* sqrt(Nan) = Nan */ 40 - return ieee754sp_nanxcpt(x); 40 + return x; 41 41 42 42 case IEEE754_CLASS_SNAN: 43 43 ieee754_setcx(IEEE754_INVALID_OPERATION); ··· 51 51 if (xs) { 52 52 /* sqrt(-Inf) = Nan */ 53 53 ieee754_setcx(IEEE754_INVALID_OPERATION); 54 - return ieee754sp_nanxcpt(ieee754sp_indef()); 54 + return ieee754sp_indef(); 55 55 } 56 56 /* sqrt(+Inf) = Inf */ 57 57 return x; ··· 61 61 if (xs) { 62 62 /* sqrt(-x) = Nan */ 63 63 ieee754_setcx(IEEE754_INVALID_OPERATION); 64 - return ieee754sp_nanxcpt(ieee754sp_indef()); 64 + return ieee754sp_indef(); 65 65 } 66 66 break; 67 67 }