Patch "MIPS: math-emu: <MADDF|MSUBF>.<D|S>: Fix NaN propagation" has been added to the 4.13-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
MIPS: math-emu: <MADDF|MSUBF>.<D|S>: Fix NaN propagation
to the 4.13-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
mips-math-emu-maddf-msubf-.-d-s-fix-nan-propagation.patch
and it can be found in the queue-4.13 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
e840be6e7057757befc3581e1699e30fe7f0dd51Mon Sep 17 00:00:00 2001
From: Aleksandar Markovic <[email protected]>
Date: Thu, 27 Jul 2017 18:08:54 +0200
Subject: MIPS: math-emu: <MADDF|MSUBF>.<D|S>: Fix NaN propagation
From: Aleksandar Markovic <[email protected]>
commit e840be6e7057757befc3581e1699e30fe7f0dd51 upstream.
Fix the cases of <MADDF|MSUBF>.<D|S> when any of three inputs is any NaN. Correct behavior of <MADDF|MSUBF>.<D|S> fd, fs, ft is following:
- if any of inputs is sNaN, return a sNaN using following rules: if only one input is sNaN, return that one; if more than one input is sNaN, order of precedence for return value is fd, fs, ft
- if no input is sNaN, but at least one of inputs is qNaN, return a qNaN using following rules: if only one input is qNaN, return that one; if more than one input is qNaN, order of precedence for return value is fd, fs, ft
The previous code contained correct handling of some above cases, but not all. Also, such handling was scattered into various cases of "switch (CLPAIR(xc, yc))" statement, and elsewhere. With this patch, this logic is placed in one place, and "switch (CLPAIR(xc, yc))" is significantly simplified.
A relevant example:
MADDF.S fd,fs,ft:
If fs contains qNaN1, ft contains qNaN2, and fd contains qNaN3, fd is going to contain qNaN3 (without this patch, it used to contain qNaN1).
Patchwork: https://patchwork.linux-mips.org/patch/16886/
--- arch/mips/math-emu/dp_maddf.c | 66 ++++++++++++------------------------------ arch/mips/math-emu/sp_maddf.c | 66 +++++++++++++----------------------------- 2 files changed, 41 insertions(+), 91 deletions(-)
arch/mips/math-emu/dp_maddf.c +20 -46
@@ -48,52 +48,34 @@ static union ieee754dp _dp_maddf(union iieee754_clearcx (); -switch (zc) { -case IEEE754_CLASS_SNAN : -ieee754_setcx (IEEE754_INVALID_OPERATION ); +/* +* Handle the cases when at least one of x, y or z is a NaN. +* Order of precedence is sNaN, qNaN and z, x, y. +*/ +if (zc ==IEEE754_CLASS_SNAN )return ieee754dp_nanxcpt (z); -case IEEE754_CLASS_DNORM : -DPDNORMZ ; -/* QNAN and ZERO cases are handled separately below */ - } - -switch (CLPAIR (xc, yc)) { -case CLPAIR (IEEE754_CLASS_QNAN ,IEEE754_CLASS_SNAN ): -case CLPAIR (IEEE754_CLASS_ZERO ,IEEE754_CLASS_SNAN ): -case CLPAIR (IEEE754_CLASS_NORM ,IEEE754_CLASS_SNAN ): -case CLPAIR (IEEE754_CLASS_DNORM ,IEEE754_CLASS_SNAN ): -case CLPAIR (IEEE754_CLASS_INF ,IEEE754_CLASS_SNAN ): -return ieee754dp_nanxcpt (y); - -case CLPAIR (IEEE754_CLASS_SNAN ,IEEE754_CLASS_SNAN ): -case CLPAIR (IEEE754_CLASS_SNAN ,IEEE754_CLASS_QNAN ): -case CLPAIR (IEEE754_CLASS_SNAN ,IEEE754_CLASS_ZERO ): -case CLPAIR (IEEE754_CLASS_SNAN ,IEEE754_CLASS_NORM ): -case CLPAIR (IEEE754_CLASS_SNAN ,IEEE754_CLASS_DNORM ): -case CLPAIR (IEEE754_CLASS_SNAN ,IEEE754_CLASS_INF ): +if (xc ==IEEE754_CLASS_SNAN )return ieee754dp_nanxcpt (x); - -case CLPAIR (IEEE754_CLASS_ZERO ,IEEE754_CLASS_QNAN ): -case CLPAIR (IEEE754_CLASS_NORM ,IEEE754_CLASS_QNAN ): -case CLPAIR (IEEE754_CLASS_DNORM ,IEEE754_CLASS_QNAN ): -case CLPAIR (IEEE754_CLASS_INF ,IEEE754_CLASS_QNAN ): +if (yc ==IEEE754_CLASS_SNAN ) +return ieee754dp_nanxcpt (y); +if (zc ==IEEE754_CLASS_QNAN ) +return z; +if (xc ==IEEE754_CLASS_QNAN ) +return x; +if (yc ==IEEE754_CLASS_QNAN )return y; -case CLPAIR (IEEE754_CLASS_QNAN ,IEEE754_CLASS_QNAN ): -case CLPAIR (IEEE754_CLASS_QNAN ,IEEE754_CLASS_ZERO ): -case CLPAIR (IEEE754_CLASS_QNAN ,IEEE754_CLASS_NORM ): -case CLPAIR (IEEE754_CLASS_QNAN ,IEEE754_CLASS_DNORM ): -case CLPAIR (IEEE754_CLASS_QNAN ,IEEE754_CLASS_INF ): -return x; +if (zc ==IEEE754_CLASS_DNORM ) +DPDNORMZ ; +/* ZERO z cases are handled separately below */ +switch (CLPAIR (xc, yc)) {/* * Infinity handling */ case CLPAIR (IEEE754_CLASS_INF ,IEEE754_CLASS_ZERO ):case CLPAIR (IEEE754_CLASS_ZERO ,IEEE754_CLASS_INF ): -if (zc ==IEEE754_CLASS_QNAN ) -return z;ieee754_setcx (IEEE754_INVALID_OPERATION );return ieee754dp_indef ();
@@ -102,8 +84,6 @@ static union ieee754dp _dp_maddf(union icase CLPAIR (IEEE754_CLASS_INF ,IEEE754_CLASS_NORM ):case CLPAIR (IEEE754_CLASS_INF ,IEEE754_CLASS_DNORM ):case CLPAIR (IEEE754_CLASS_INF ,IEEE754_CLASS_INF ): -if (zc ==IEEE754_CLASS_QNAN ) -return z;return ieee754dp_inf (xs ^ ys);case CLPAIR (IEEE754_CLASS_ZERO ,IEEE754_CLASS_ZERO ):
@@ -120,25 +100,19 @@ static union ieee754dp _dp_maddf(union iDPDNORMX ;case CLPAIR (IEEE754_CLASS_NORM ,IEEE754_CLASS_DNORM ): -if (zc ==IEEE754_CLASS_QNAN ) -return z; -else if (zc ==IEEE754_CLASS_INF ) +if (zc ==IEEE754_CLASS_INF )return ieee754dp_inf (zs);DPDNORMY ;break ;case CLPAIR (IEEE754_CLASS_DNORM ,IEEE754_CLASS_NORM ): -if (zc ==IEEE754_CLASS_QNAN ) -return z; -else if (zc ==IEEE754_CLASS_INF ) +if (zc ==IEEE754_CLASS_INF )return ieee754dp_inf (zs);DPDNORMX ;break ;case CLPAIR (IEEE754_CLASS_NORM ,IEEE754_CLASS_NORM ): -if (zc ==IEEE754_CLASS_QNAN ) -return z; -else if (zc ==IEEE754_CLASS_INF ) +if (zc ==IEEE754_CLASS_INF )return ieee754dp_inf (zs);/* fall through to real computations */ }
arch/mips/math-emu/sp_maddf.c +21 -45
105 lines not on this page · raw message
Patches currently in stable-queue which might be from [email protected] are
queue-4.13/mips-math-emu-maddf-msubf-.-d-s-fix-nan-propagation.patch queue-4.13/mips-math-emu-max-maxa-min-mina-.-d-s-fix-cases-of-both-inputs-zero.patch queue-4.13/mips-math-emu-max-min-.-d-s-fix-cases-of-both-inputs-negative.patch queue-4.13/mips-math-emu-max-maxa-min-mina-.-d-s-fix-quiet-nan-propagation.patch queue-4.13/mips-math-emu-maddf-msubf-.d-fix-accuracy-64-bit-case.patch queue-4.13/mips-math-emu-maddf-msubf-.s-fix-accuracy-32-bit-case.patch queue-4.13/mips-math-emu-maxa-mina-.-d-s-fix-cases-of-input-values-with-opposite-signs.patch queue-4.13/mips-math-emu-maxa-mina-.-d-s-fix-cases-of-both-infinite-inputs.patch queue-4.13/mips-math-emu-mina.-d-s-fix-some-cases-of-infinity-and-zero-inputs.patch queue-4.13/mips-math-emu-maddf-msubf-.-d-s-fix-some-cases-of-zero-inputs.patch queue-4.13/mips-math-emu-maddf-msubf-.-d-s-clean-up-maddf_flags-enumeration.patch queue-4.13/mips-math-emu-maddf-msubf-.-d-s-fix-some-cases-of-infinite-inputs.patch