Patch "MIPS: math-emu: <MAX|MIN>.<D|S>: Fix cases of both inputs negative" 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: <MAX|MIN>.<D|S>: Fix cases of both inputs negative
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-max-min-.-d-s-fix-cases-of-both-inputs-negative.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
aabf5cf02e22ebc4e541adf835910f388b6c3e65Mon Sep 17 00:00:00 2001
From: Aleksandar Markovic <[email protected]>
Date: Thu, 27 Jul 2017 18:08:50 +0200
Subject: MIPS: math-emu: <MAX|MIN>.<D|S>: Fix cases of both inputs negative
From: Aleksandar Markovic <[email protected]>
commit aabf5cf02e22ebc4e541adf835910f388b6c3e65 upstream.
Fix the value returned by <MAX|MIN>.<D|S>, if both inputs are negative normal fp numbers. The previous logic did not take into account that if both inputs have the same sign, there should be separate treatment of the cases when both inputs are negative and when both inputs are positive.
A relevant example:
MAX.S fd,fs,ft:
If fs contains -5.0, and ft contains -7.0, fd is going to contain -5.0 (without this patch, it used to contain -7.0).
Patchwork: https://patchwork.linux-mips.org/patch/16882/
--- arch/mips/math-emu/dp_fmax.c | 32 ++++++++++++++++++++++++-------- arch/mips/math-emu/dp_fmin.c | 32 ++++++++++++++++++++++++-------- arch/mips/math-emu/sp_fmax.c | 32 ++++++++++++++++++++++++-------- arch/mips/math-emu/sp_fmin.c | 32 ++++++++++++++++++++++++-------- 4 files changed, 96 insertions(+), 32 deletions(-)
arch/mips/math-emu/dp_fmax.c +24 -8
@@ -116,16 +116,32 @@ union ieee754dp ieee754dp_fmax(union ieeelse if (xs < ys)return x; -/* Compare exponent */ -if (xe > ye) -return x; -else if (xe < ye) -return y; +/* Signs of inputs are equal, let's compare exponents */ +if (xs ==0 ) { +/* Inputs are both positive */ +if (xe > ye) +return x; +else if (xe < ye) +return y; + }else { +/* Inputs are both negative */ +if (xe > ye) +return y; +else if (xe < ye) +return x; + } -/* Compare mantissa */ +/* Signs and exponents of inputs are equal, let's compare mantissas */ +if (xs ==0 ) { +/* Inputs are both positive, with equal signs and exponents */ +if (xm <= ym) +return y; +return x; + } +/* Inputs are both negative, with equal signs and exponents */ if (xm <= ym) -return y; -return x; +return x; +return y; }union ieee754dp ieee754dp_fmaxa (union ieee754dp x,union ieee754dp y)
arch/mips/math-emu/dp_fmin.c +24 -8
@@ -116,16 +116,32 @@ union ieee754dp ieee754dp_fmin(union ieeelse if (xs < ys)return y; -/* Compare exponent */ -if (xe > ye) -return y; -else if (xe < ye) -return x; +/* Signs of inputs are the same, let's compare exponents */ +if (xs ==0 ) { +/* Inputs are both positive */ +if (xe > ye) +return y; +else if (xe < ye) +return x; + }else { +/* Inputs are both negative */ +if (xe > ye) +return x; +else if (xe < ye) +return y; + } -/* Compare mantissa */ +/* Signs and exponents of inputs are equal, let's compare mantissas */ +if (xs ==0 ) { +/* Inputs are both positive, with equal signs and exponents */ +if (xm <= ym) +return x; +return y; + } +/* Inputs are both negative, with equal signs and exponents */ if (xm <= ym) -return x; -return y; +return y; +return x; }union ieee754dp ieee754dp_fmina (union ieee754dp x,union ieee754dp y)
arch/mips/math-emu/sp_fmax.c +24 -8
@@ -116,16 +116,32 @@ union ieee754sp ieee754sp_fmax(union ieeelse if (xs < ys)return x; -/* Compare exponent */ -if (xe > ye) -return x; -else if (xe < ye) -return y; +/* Signs of inputs are equal, let's compare exponents */ +if (xs ==0 ) { +/* Inputs are both positive */ +if (xe > ye) +return x; +else if (xe < ye) +return y; + }else { +/* Inputs are both negative */ +if (xe > ye) +return y; +else if (xe < ye) +return x; + } -/* Compare mantissa */ +/* Signs and exponents of inputs are equal, let's compare mantissas */ +if (xs ==0 ) { +/* Inputs are both positive, with equal signs and exponents */ +if (xm <= ym) +return y; +return x; + } +/* Inputs are both negative, with equal signs and exponents */ if (xm <= ym) -return y; -return x; +return x; +return y; }union ieee754sp ieee754sp_fmaxa (union ieee754sp x,union ieee754sp y)
arch/mips/math-emu/sp_fmin.c +24 -8
@@ -116,16 +116,32 @@ union ieee754sp ieee754sp_fmin(union ieeelse if (xs < ys)return y; -/* Compare exponent */ -if (xe > ye) -return y; -else if (xe < ye) -return x; +/* Signs of inputs are the same, let's compare exponents */ +if (xs ==0 ) { +/* Inputs are both positive */ +if (xe > ye) +return y; +else if (xe < ye) +return x; + }else { +/* Inputs are both negative */ +if (xe > ye) +return x; +else if (xe < ye) +return y; + } -/* Compare mantissa */ +/* Signs and exponents of inputs are equal, let's compare mantissas */ +if (xs ==0 ) { +/* Inputs are both positive, with equal signs and exponents */ +if (xm <= ym) +return x; +return y; + } +/* Inputs are both negative, with equal signs and exponents */ if (xm <= ym) -return x; -return y; +return y; +return x; }union ieee754sp ieee754sp_fmina (union ieee754sp x,union ieee754sp y)
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