Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1693782
| From | James Hogan <james.hogan@imgtec.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v3 07/16] MIPS: math-emu: <MAX|MIN>.<D|S>: Fix cases of both inputs negative |
| Date | 2017-07-21 17:20 +0200 |
| Message-ID | <u5HSG-6sw-9@gated-at.bofh.it> (permalink) |
| References | <u5GWB-5Tl-3@gated-at.bofh.it> <u5GWD-5Tl-51@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
On Fri, Jul 21, 2017 at 04:09:05PM +0200, Aleksandar Markovic wrote:
> From: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
>
> 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.
>
> The relevant example:
>
> MAX.S fd,fs,ft:
> If fs contains -5, and ft contains -7, fd is going to contain -5
> (without this patch, it used to contain -7).
ouch!
>
same fixes/stable comment as for previous min/max patches
> Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com>
> Signed-off-by: Goran Ferenc <goran.ferenc@imgtec.com>
> Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
Reviewed-by: James Hogan <james.hogan@imgtec.com>
Cheers
James
> ---
> arch/mips/math-emu/dp_fmax.c | 33 +++++++++++++++++++++++++--------
> arch/mips/math-emu/dp_fmin.c | 33 +++++++++++++++++++++++++--------
> arch/mips/math-emu/sp_fmax.c | 33 +++++++++++++++++++++++++--------
> arch/mips/math-emu/sp_fmin.c | 32 +++++++++++++++++++++++++-------
> 4 files changed, 100 insertions(+), 31 deletions(-)
>
> diff --git a/arch/mips/math-emu/dp_fmax.c b/arch/mips/math-emu/dp_fmax.c
> index 9517572..a0175cc 100644
> --- a/arch/mips/math-emu/dp_fmax.c
> +++ b/arch/mips/math-emu/dp_fmax.c
> @@ -106,16 +106,33 @@ union ieee754dp ieee754dp_fmax(union ieee754dp x, union ieee754dp y)
> else if (xs < ys)
> return x;
>
> - /* Compare exponent */
> - if (xe > ye)
> - return x;
> - else if (xe < ye)
> - return y;
> + /* Signs of inputs are the same, 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 */
> - if (xm <= ym)
> + /* Signs and exponents of inputs are the same, let's compare mantissas */
> + if (xs == 0) {
> + /* Inputs are both positive, with equal exponents */
> + if (xm <= ym)
> + return y;
> + return x;
> + } else {
> + /* Inputs are both negative, with equal exponents */
> + if (xm <= ym)
> + return x;
> return y;
> - return x;
> + }
> }
>
> union ieee754dp ieee754dp_fmaxa(union ieee754dp x, union ieee754dp y)
> diff --git a/arch/mips/math-emu/dp_fmin.c b/arch/mips/math-emu/dp_fmin.c
> index 7069320..074a858 100644
> --- a/arch/mips/math-emu/dp_fmin.c
> +++ b/arch/mips/math-emu/dp_fmin.c
> @@ -106,16 +106,33 @@ union ieee754dp ieee754dp_fmin(union ieee754dp x, union ieee754dp y)
> else 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 */
> - if (xm <= ym)
> + /* Signs and exponents of inputs are the same, let's compare mantissas */
> + if (xs == 0) {
> + /* Inputs are both positive, with equal exponents */
> + if (xm <= ym)
> + return x;
> + return y;
> + } else {
> + /* Inputs are both negative, with equal exponents */
> + if (xm <= ym)
> + return y;
> return x;
> - return y;
> + }
> }
>
> union ieee754dp ieee754dp_fmina(union ieee754dp x, union ieee754dp y)
> diff --git a/arch/mips/math-emu/sp_fmax.c b/arch/mips/math-emu/sp_fmax.c
> index d72111a..15825db 100644
> --- a/arch/mips/math-emu/sp_fmax.c
> +++ b/arch/mips/math-emu/sp_fmax.c
> @@ -106,16 +106,33 @@ union ieee754sp ieee754sp_fmax(union ieee754sp x, union ieee754sp y)
> else if (xs < ys)
> return x;
>
> - /* Compare exponent */
> - if (xe > ye)
> - return x;
> - else if (xe < ye)
> - return y;
> + /* Signs of inputs are the same, 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 */
> - if (xm <= ym)
> + /* Signs and exponents of inputs are the same, let's compare mantissas */
> + if (xs == 0) {
> + /* Inputs are both positive, with equal exponents */
> + if (xm <= ym)
> + return y;
> + return x;
> + } else {
> + /* Inputs are both negative, with equal exponents */
> + if (xm <= ym)
> + return x;
> return y;
> - return x;
> + }
> }
>
> union ieee754sp ieee754sp_fmaxa(union ieee754sp x, union ieee754sp y)
> diff --git a/arch/mips/math-emu/sp_fmin.c b/arch/mips/math-emu/sp_fmin.c
> index 61ff9c6..f1418f7 100644
> --- a/arch/mips/math-emu/sp_fmin.c
> +++ b/arch/mips/math-emu/sp_fmin.c
> @@ -106,16 +106,34 @@ union ieee754sp ieee754sp_fmin(union ieee754sp x, union ieee754sp y)
> else if (xs < ys)
> return y;
>
> - /* Compare exponent */
> - if (xe > ye)
> + /* 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;
> + }
> +
> + /* Signs and exponents of inputs are the same, let's compare mantissas */
> + if (xs == 0) {
> + /* Inputs are both positive, with equal exponents */
> + if (xm <= ym)
> + return x;
> return y;
> - else if (xe < ye)
> + } else {
> + /* Inputs are both negative, with equal exponents */
> + if (xm <= ym)
> + return y;
> return x;
> + }
>
> - /* Compare mantissa */
> - if (xm <= ym)
> - return x;
> - return y;
> }
>
> union ieee754sp ieee754sp_fmina(union ieee754sp x, union ieee754sp y)
> --
> 2.7.4
>
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v3 00/16] MIPS: Miscellaneous fixes related to Android Mips emulator Aleksandar Markovic <aleksandar.markovic@rt-rk.com> - 2017-07-21 16:20 +0200
[PATCH v3 07/16] MIPS: math-emu: <MAX|MIN>.<D|S>: Fix cases of both inputs negative Aleksandar Markovic <aleksandar.markovic@rt-rk.com> - 2017-07-21 16:20 +0200
Re: [PATCH v3 07/16] MIPS: math-emu: <MAX|MIN>.<D|S>: Fix cases of both inputs negative James Hogan <james.hogan@imgtec.com> - 2017-07-21 17:20 +0200
[PATCH v3 04/16] MIPS: VDSO: Fix clobber lists in fallback code paths Aleksandar Markovic <aleksandar.markovic@rt-rk.com> - 2017-07-21 16:20 +0200
Re: [PATCH v3 04/16] MIPS: VDSO: Fix clobber lists in fallback code paths James Hogan <james.hogan@imgtec.com> - 2017-07-21 16:30 +0200
csiph-web