Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1693737 > unrolled thread

[PATCH v3 08/16] MIPS: math-emu: <MAXA|MINA>.<D|S>: Fix cases of input values with opposite signs

Started byAleksandar Markovic <aleksandar.markovic@rt-rk.com>
First post2017-07-21 16:20 +0200
Last post2017-07-24 15:00 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v3 08/16] MIPS: math-emu: <MAXA|MINA>.<D|S>: Fix cases of input values with opposite signs Aleksandar Markovic <aleksandar.markovic@rt-rk.com> - 2017-07-21 16:20 +0200
    Re: [PATCH v3 08/16] MIPS: math-emu: <MAXA|MINA>.<D|S>: Fix cases of  input values with opposite signs James Hogan <james.hogan@imgtec.com> - 2017-07-21 17:50 +0200
      RE: [PATCH v3 08/16] MIPS: math-emu: <MAXA|MINA>.<D|S>: Fix cases  of input values with opposite signs Aleksandar Markovic <Aleksandar.Markovic@imgtec.com> - 2017-07-24 15:00 +0200

#1693737 — [PATCH v3 08/16] MIPS: math-emu: <MAXA|MINA>.<D|S>: Fix cases of input values with opposite signs

FromAleksandar Markovic <aleksandar.markovic@rt-rk.com>
Date2017-07-21 16:20 +0200
Subject[PATCH v3 08/16] MIPS: math-emu: <MAXA|MINA>.<D|S>: Fix cases of input values with opposite signs
Message-ID<u5GWC-5Tl-39@gated-at.bofh.it>
From: Aleksandar Markovic <aleksandar.markovic@imgtec.com>

Fix the value returned by <MAXA|MINA>.<D|S>, if inputs are normal fp
numbers of the same absolute value, but opposite signs.

The relevant example:

MAXA.S fd,fs,ft:
  If fs contains -3, and ft contains +3, fd is going to contain +3
  (without this patch, it used to contain -3).

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>
---
 arch/mips/math-emu/dp_fmax.c | 8 ++++++--
 arch/mips/math-emu/dp_fmin.c | 6 +++++-
 arch/mips/math-emu/sp_fmax.c | 8 ++++++--
 arch/mips/math-emu/sp_fmin.c | 6 +++++-
 4 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/arch/mips/math-emu/dp_fmax.c b/arch/mips/math-emu/dp_fmax.c
index a0175cc..860b43f9 100644
--- a/arch/mips/math-emu/dp_fmax.c
+++ b/arch/mips/math-emu/dp_fmax.c
@@ -224,7 +224,11 @@ union ieee754dp ieee754dp_fmaxa(union ieee754dp x, union ieee754dp y)
 		return y;
 
 	/* Compare mantissa */
-	if (xm <= ym)
+	if (xm < ym)
 		return y;
-	return x;
+	else if (xm > ym)
+		return x;
+	else if (xs == 0)
+		return x;
+	return y;
 }
diff --git a/arch/mips/math-emu/dp_fmin.c b/arch/mips/math-emu/dp_fmin.c
index 074a858..73d85e4 100644
--- a/arch/mips/math-emu/dp_fmin.c
+++ b/arch/mips/math-emu/dp_fmin.c
@@ -224,7 +224,11 @@ union ieee754dp ieee754dp_fmina(union ieee754dp x, union ieee754dp y)
 		return x;
 
 	/* Compare mantissa */
-	if (xm <= ym)
+	if (xm < ym)
+		return x;
+	else if (xm > ym)
+		return y;
+	else if (xs == 1)
 		return x;
 	return y;
 }
diff --git a/arch/mips/math-emu/sp_fmax.c b/arch/mips/math-emu/sp_fmax.c
index 15825db..fec7f64 100644
--- a/arch/mips/math-emu/sp_fmax.c
+++ b/arch/mips/math-emu/sp_fmax.c
@@ -224,7 +224,11 @@ union ieee754sp ieee754sp_fmaxa(union ieee754sp x, union ieee754sp y)
 		return y;
 
 	/* Compare mantissa */
-	if (xm <= ym)
+	if (xm < ym)
 		return y;
-	return x;
+	else if (xm > ym)
+		return x;
+	else if (xs == 0)
+		return x;
+	return y;
 }
diff --git a/arch/mips/math-emu/sp_fmin.c b/arch/mips/math-emu/sp_fmin.c
index f1418f7..74780bc 100644
--- a/arch/mips/math-emu/sp_fmin.c
+++ b/arch/mips/math-emu/sp_fmin.c
@@ -225,7 +225,11 @@ union ieee754sp ieee754sp_fmina(union ieee754sp x, union ieee754sp y)
 		return x;
 
 	/* Compare mantissa */
-	if (xm <= ym)
+	if (xm < ym)
+		return x;
+	else if (xm > ym)
+		return y;
+	else if (xs == 1)
 		return x;
 	return y;
 }
-- 
2.7.4

[toc] | [next] | [standalone]


#1693810 — Re: [PATCH v3 08/16] MIPS: math-emu: <MAXA|MINA>.<D|S>: Fix cases of input values with opposite signs

FromJames Hogan <james.hogan@imgtec.com>
Date2017-07-21 17:50 +0200
SubjectRe: [PATCH v3 08/16] MIPS: math-emu: <MAXA|MINA>.<D|S>: Fix cases of input values with opposite signs
Message-ID<u5IlI-6Ek-23@gated-at.bofh.it>
In reply to#1693737

[Multipart message — attachments visible in raw view] — view raw

On Fri, Jul 21, 2017 at 04:09:06PM +0200, Aleksandar Markovic wrote:
> From: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
> 
> Fix the value returned by <MAXA|MINA>.<D|S>, if inputs are normal fp
> numbers of the same absolute value, but opposite signs.
> 
> The relevant example:
> 
> MAXA.S fd,fs,ft:
>   If fs contains -3, and ft contains +3, fd is going to contain +3
>   (without this patch, it used to contain -3).

I think its worth mentioning also that for MINA.*, it returns the
negative one when the absolute values are equal (The phrase "For equal
absolute values, returns the smallest positive argument" in the manual
is a bit ambiguous IMO, so I ended up checking what I6500 did).

> 

Usual fixes/stable thing.

> 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>

Thanks
James

> ---
>  arch/mips/math-emu/dp_fmax.c | 8 ++++++--
>  arch/mips/math-emu/dp_fmin.c | 6 +++++-
>  arch/mips/math-emu/sp_fmax.c | 8 ++++++--
>  arch/mips/math-emu/sp_fmin.c | 6 +++++-
>  4 files changed, 22 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/mips/math-emu/dp_fmax.c b/arch/mips/math-emu/dp_fmax.c
> index a0175cc..860b43f9 100644
> --- a/arch/mips/math-emu/dp_fmax.c
> +++ b/arch/mips/math-emu/dp_fmax.c
> @@ -224,7 +224,11 @@ union ieee754dp ieee754dp_fmaxa(union ieee754dp x, union ieee754dp y)
>  		return y;
>  
>  	/* Compare mantissa */
> -	if (xm <= ym)
> +	if (xm < ym)
>  		return y;
> -	return x;
> +	else if (xm > ym)
> +		return x;
> +	else if (xs == 0)
> +		return x;
> +	return y;
>  }
> diff --git a/arch/mips/math-emu/dp_fmin.c b/arch/mips/math-emu/dp_fmin.c
> index 074a858..73d85e4 100644
> --- a/arch/mips/math-emu/dp_fmin.c
> +++ b/arch/mips/math-emu/dp_fmin.c
> @@ -224,7 +224,11 @@ union ieee754dp ieee754dp_fmina(union ieee754dp x, union ieee754dp y)
>  		return x;
>  
>  	/* Compare mantissa */
> -	if (xm <= ym)
> +	if (xm < ym)
> +		return x;
> +	else if (xm > ym)
> +		return y;
> +	else if (xs == 1)
>  		return x;
>  	return y;
>  }
> diff --git a/arch/mips/math-emu/sp_fmax.c b/arch/mips/math-emu/sp_fmax.c
> index 15825db..fec7f64 100644
> --- a/arch/mips/math-emu/sp_fmax.c
> +++ b/arch/mips/math-emu/sp_fmax.c
> @@ -224,7 +224,11 @@ union ieee754sp ieee754sp_fmaxa(union ieee754sp x, union ieee754sp y)
>  		return y;
>  
>  	/* Compare mantissa */
> -	if (xm <= ym)
> +	if (xm < ym)
>  		return y;
> -	return x;
> +	else if (xm > ym)
> +		return x;
> +	else if (xs == 0)
> +		return x;
> +	return y;
>  }
> diff --git a/arch/mips/math-emu/sp_fmin.c b/arch/mips/math-emu/sp_fmin.c
> index f1418f7..74780bc 100644
> --- a/arch/mips/math-emu/sp_fmin.c
> +++ b/arch/mips/math-emu/sp_fmin.c
> @@ -225,7 +225,11 @@ union ieee754sp ieee754sp_fmina(union ieee754sp x, union ieee754sp y)
>  		return x;
>  
>  	/* Compare mantissa */
> -	if (xm <= ym)
> +	if (xm < ym)
> +		return x;
> +	else if (xm > ym)
> +		return y;
> +	else if (xs == 1)
>  		return x;
>  	return y;
>  }
> -- 
> 2.7.4
> 

[toc] | [prev] | [next] | [standalone]


#1694688 — RE: [PATCH v3 08/16] MIPS: math-emu: <MAXA|MINA>.<D|S>: Fix cases of input values with opposite signs

FromAleksandar Markovic <Aleksandar.Markovic@imgtec.com>
Date2017-07-24 15:00 +0200
SubjectRE: [PATCH v3 08/16] MIPS: math-emu: <MAXA|MINA>.<D|S>: Fix cases of input values with opposite signs
Message-ID<u6L7Q-4Yh-23@gated-at.bofh.it>
In reply to#1693810
> 
> ________________________________________
> From: James Hogan
> Sent: Friday, July 21, 2017 8:42 AM
> To: Aleksandar Markovic
> Cc: linux-mips@linux-mips.org; Aleksandar Markovic; Miodrag Dinic; Goran Ferenc; Douglas Leung; linux-kernel@vger.kernel.org; Paul Burton; Petar Jovanovic; Raghu Gandham; Ralf Baechle
> Subject: Re: [PATCH v3 08/16] MIPS: math-emu: <MAXA|MINA>.<D|S>: Fix cases of input values with opposite signs
> 
> On Fri, Jul 21, 2017 at 04:09:06PM +0200, Aleksandar Markovic wrote:
> > From: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
> >
> > Fix the value returned by <MAXA|MINA>.<D|S>, if inputs are normal fp
> > numbers of the same absolute value, but opposite signs.
> >
> > The relevant example:
> >
> > MAXA.S fd,fs,ft:
> >   If fs contains -3, and ft contains +3, fd is going to contain +3
> >   (without this patch, it used to contain -3).
> 
> I think its worth mentioning also that for MINA.*, it returns the
> negative one when the absolute values are equal (The phrase "For equal
> absolute values, returns the smallest positive argument" in the manual
> is a bit ambiguous IMO, so I ended up checking what I6500 did).

I am going to slightly rephrase the commit messege to address this.

Regards,
Aleksandar

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web