Commit 539bfb57 authored by Maciej W. Rozycki's avatar Maciej W. Rozycki Committed by Ralf Baechle

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: default avatarMaciej W. Rozycki <macro@linux-mips.org>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/9687/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent d19cf86e
...@@ -44,7 +44,7 @@ union ieee754dp ieee754dp_fsp(union ieee754sp x) ...@@ -44,7 +44,7 @@ union ieee754dp ieee754dp_fsp(union ieee754sp x)
return ieee754dp_nanxcpt(ieee754dp_indef()); return ieee754dp_nanxcpt(ieee754dp_indef());
case IEEE754_CLASS_QNAN: case IEEE754_CLASS_QNAN:
return ieee754dp_nanxcpt(ieee754dp_nan_fsp(xs, xm)); return ieee754dp_nan_fsp(xs, xm);
case IEEE754_CLASS_INF: case IEEE754_CLASS_INF:
return ieee754dp_inf(xs); return ieee754dp_inf(xs);
......
...@@ -44,7 +44,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x) ...@@ -44,7 +44,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x)
switch (xc) { switch (xc) {
case IEEE754_CLASS_QNAN: case IEEE754_CLASS_QNAN:
/* sqrt(Nan) = Nan */ /* sqrt(Nan) = Nan */
return ieee754dp_nanxcpt(x); return x;
case IEEE754_CLASS_SNAN: case IEEE754_CLASS_SNAN:
ieee754_setcx(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
...@@ -58,7 +58,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x) ...@@ -58,7 +58,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x)
if (xs) { if (xs) {
/* sqrt(-Inf) = Nan */ /* sqrt(-Inf) = Nan */
ieee754_setcx(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef()); return ieee754dp_indef();
} }
/* sqrt(+Inf) = Inf */ /* sqrt(+Inf) = Inf */
return x; return x;
...@@ -71,7 +71,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x) ...@@ -71,7 +71,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x)
if (xs) { if (xs) {
/* sqrt(-x) = Nan */ /* sqrt(-x) = Nan */
ieee754_setcx(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef()); return ieee754dp_indef();
} }
break; break;
} }
......
...@@ -50,7 +50,7 @@ union ieee754sp ieee754sp_fdp(union ieee754dp x) ...@@ -50,7 +50,7 @@ union ieee754sp ieee754sp_fdp(union ieee754dp x)
nan = ieee754sp_nan_fdp(xs, xm); nan = ieee754sp_nan_fdp(xs, xm);
if (!ieee754sp_isnan(nan)) if (!ieee754sp_isnan(nan))
nan = ieee754sp_indef(); nan = ieee754sp_indef();
return ieee754sp_nanxcpt(nan); return nan;
case IEEE754_CLASS_INF: case IEEE754_CLASS_INF:
return ieee754sp_inf(xs); return ieee754sp_inf(xs);
......
...@@ -37,7 +37,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x) ...@@ -37,7 +37,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x)
switch (xc) { switch (xc) {
case IEEE754_CLASS_QNAN: case IEEE754_CLASS_QNAN:
/* sqrt(Nan) = Nan */ /* sqrt(Nan) = Nan */
return ieee754sp_nanxcpt(x); return x;
case IEEE754_CLASS_SNAN: case IEEE754_CLASS_SNAN:
ieee754_setcx(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
...@@ -51,7 +51,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x) ...@@ -51,7 +51,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x)
if (xs) { if (xs) {
/* sqrt(-Inf) = Nan */ /* sqrt(-Inf) = Nan */
ieee754_setcx(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef()); return ieee754sp_indef();
} }
/* sqrt(+Inf) = Inf */ /* sqrt(+Inf) = Inf */
return x; return x;
...@@ -61,7 +61,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x) ...@@ -61,7 +61,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x)
if (xs) { if (xs) {
/* sqrt(-x) = Nan */ /* sqrt(-x) = Nan */
ieee754_setcx(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef()); return ieee754sp_indef();
} }
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment