On Fri, Jul 21, 2017 at 04:09:03PM +0200, Aleksandar Markovic wrote: > From: Aleksandar Markovic <aleksandar.markovic@xxxxxxxxxx> > > Fix the value returned by <MAX|MAXA|MIN|MINA>.<D|S>, if both inputs > are quiet NaNs. The specifications of <MAX|MAXA|MIN|MINA>.<D|S> state > that the returned value in such cases should be the quiet NaN > contained in register fs. > > The relevant example: > > MAX.S fd,fs,ft: > If fs contains qNaN1, and ft contains qNaN2, fd is going to contain > qNaN1 (without this patch, it used to contain qNaN2). > Consider adding: Fixes: a79f5f9ba508 ("MIPS: math-emu: Add support for the MIPS R6 MAX{, A} FPU instruction") Fixes: 4e9561b20e2f ("MIPS: math-emu: Add support for the MIPS R6 MIN{, A} FPU instruction") > Signed-off-by: Miodrag Dinic <miodrag.dinic@xxxxxxxxxx> > Signed-off-by: Goran Ferenc <goran.ferenc@xxxxxxxxxx> > Signed-off-by: Aleksandar Markovic <aleksandar.markovic@xxxxxxxxxx> Consider adding: Cc: <stable@xxxxxxxxxxxxxxx> # 4.3+ > --- > arch/mips/math-emu/dp_fmax.c | 8 ++++++-- > arch/mips/math-emu/dp_fmin.c | 8 ++++++-- > arch/mips/math-emu/sp_fmax.c | 8 ++++++-- > arch/mips/math-emu/sp_fmin.c | 8 ++++++-- > 4 files changed, 24 insertions(+), 8 deletions(-) > > diff --git a/arch/mips/math-emu/dp_fmax.c b/arch/mips/math-emu/dp_fmax.c > index fd71b8d..567fc33 100644 > --- a/arch/mips/math-emu/dp_fmax.c > +++ b/arch/mips/math-emu/dp_fmax.c > @@ -47,6 +47,9 @@ union ieee754dp ieee754dp_fmax(union ieee754dp x, union ieee754dp y) > case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): > return ieee754dp_nanxcpt(x); > > + case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): > + return x; couldn't the above... > + > /* numbers are preferred to NaNs */ > case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): > case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): > @@ -54,7 +57,6 @@ union ieee754dp ieee754dp_fmax(union ieee754dp x, union ieee754dp y) ... go somewhere around here and fall through to the existing return x case? and same below of course. Otherwise: Reviewed-by: James Hogan <james.hogan@xxxxxxxxxx> Cheers James > case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): > return x; > > - 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): > @@ -147,6 +149,9 @@ union ieee754dp ieee754dp_fmaxa(union ieee754dp x, union ieee754dp y) > case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): > return ieee754dp_nanxcpt(x); > > + case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): > + return x; > + > /* numbers are preferred to NaNs */ > case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): > case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): > @@ -154,7 +159,6 @@ union ieee754dp ieee754dp_fmaxa(union ieee754dp x, union ieee754dp y) > case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): > return x; > > - 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): > diff --git a/arch/mips/math-emu/dp_fmin.c b/arch/mips/math-emu/dp_fmin.c > index c1072b0..77f7ca9 100644 > --- a/arch/mips/math-emu/dp_fmin.c > +++ b/arch/mips/math-emu/dp_fmin.c > @@ -47,6 +47,9 @@ union ieee754dp ieee754dp_fmin(union ieee754dp x, union ieee754dp y) > case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): > return ieee754dp_nanxcpt(x); > > + case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): > + return x; > + > /* numbers are preferred to NaNs */ > case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): > case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): > @@ -54,7 +57,6 @@ union ieee754dp ieee754dp_fmin(union ieee754dp x, union ieee754dp y) > case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): > return x; > > - 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): > @@ -147,6 +149,9 @@ union ieee754dp ieee754dp_fmina(union ieee754dp x, union ieee754dp y) > case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): > return ieee754dp_nanxcpt(x); > > + case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): > + return x; > + > /* numbers are preferred to NaNs */ > case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): > case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): > @@ -154,7 +159,6 @@ union ieee754dp ieee754dp_fmina(union ieee754dp x, union ieee754dp y) > case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): > return x; > > - 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): > diff --git a/arch/mips/math-emu/sp_fmax.c b/arch/mips/math-emu/sp_fmax.c > index 4d00084..d46e8e4 100644 > --- a/arch/mips/math-emu/sp_fmax.c > +++ b/arch/mips/math-emu/sp_fmax.c > @@ -47,6 +47,9 @@ union ieee754sp ieee754sp_fmax(union ieee754sp x, union ieee754sp y) > case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): > return ieee754sp_nanxcpt(x); > > + case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): > + return x; > + > /* numbers are preferred to NaNs */ > case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): > case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): > @@ -54,7 +57,6 @@ union ieee754sp ieee754sp_fmax(union ieee754sp x, union ieee754sp y) > case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): > return x; > > - 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): > @@ -147,6 +149,9 @@ union ieee754sp ieee754sp_fmaxa(union ieee754sp x, union ieee754sp y) > case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): > return ieee754sp_nanxcpt(x); > > + case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): > + return x; > + > /* numbers are preferred to NaNs */ > case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): > case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): > @@ -154,7 +159,6 @@ union ieee754sp ieee754sp_fmaxa(union ieee754sp x, union ieee754sp y) > case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): > return x; > > - 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): > diff --git a/arch/mips/math-emu/sp_fmin.c b/arch/mips/math-emu/sp_fmin.c > index 4eb1bb9..b528c4b 100644 > --- a/arch/mips/math-emu/sp_fmin.c > +++ b/arch/mips/math-emu/sp_fmin.c > @@ -47,6 +47,9 @@ union ieee754sp ieee754sp_fmin(union ieee754sp x, union ieee754sp y) > case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): > return ieee754sp_nanxcpt(x); > > + case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): > + return x; > + > /* numbers are preferred to NaNs */ > case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): > case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): > @@ -54,7 +57,6 @@ union ieee754sp ieee754sp_fmin(union ieee754sp x, union ieee754sp y) > case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): > return x; > > - 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): > @@ -147,6 +149,9 @@ union ieee754sp ieee754sp_fmina(union ieee754sp x, union ieee754sp y) > case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): > return ieee754sp_nanxcpt(x); > > + case CLPAIR(IEEE754_CLASS_QNAN, IEEE754_CLASS_QNAN): > + return x; > + > /* numbers are preferred to NaNs */ > case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): > case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN): > @@ -154,7 +159,6 @@ union ieee754sp ieee754sp_fmina(union ieee754sp x, union ieee754sp y) > case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_QNAN): > return x; > > - 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): > -- > 2.7.4 >
Attachment:
signature.asc
Description: Digital signature