* [PATCH] Fix absd emulation
@ 2009-07-10 8:50 Raghu Gandham
2009-10-12 16:15 ` Ralf Baechle
0 siblings, 1 reply; 11+ messages in thread
From: Raghu Gandham @ 2009-07-10 8:50 UTC (permalink / raw)
To: linux-mips; +Cc: raghu, chris
From: Robin Randhawa <robin@mips.com>
Signed-off-by: Chris Dearman <chris@mips.com>
---
arch/mips/math-emu/dp_simple.c | 11 ++++-------
arch/mips/math-emu/sp_simple.c | 3 ---
2 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/arch/mips/math-emu/dp_simple.c b/arch/mips/math-emu/dp_simple.c
index 1c555e6..6ff4655 100644
--- a/arch/mips/math-emu/dp_simple.c
+++ b/arch/mips/math-emu/dp_simple.c
@@ -76,15 +76,12 @@ ieee754dp ieee754dp_abs(ieee754dp x)
CLEARCX;
FLUSHXDP;
+ /* Clear sign ALWAYS, irrespective of NaN */
+ DPSIGN(x) = 0;
+
if (xc == IEEE754_CLASS_SNAN) {
SETCX(IEEE754_INVALID_OPERATION);
- return ieee754dp_nanxcpt(ieee754dp_indef(), "neg");
+ return ieee754dp_nanxcpt(ieee754dp_indef(), "abs");
}
-
- if (ieee754dp_isnan(x)) /* but not infinity */
- return ieee754dp_nanxcpt(x, "abs", x);
-
- /* quick fix up */
- DPSIGN(x) = 0;
return x;
}
diff --git a/arch/mips/math-emu/sp_simple.c b/arch/mips/math-emu/sp_simple.c
index 770f0f4..cdec1a2 100644
--- a/arch/mips/math-emu/sp_simple.c
+++ b/arch/mips/math-emu/sp_simple.c
@@ -61,9 +61,6 @@ ieee754sp ieee754sp_neg(ieee754sp x)
SPSIGN(y) = SPSIGN(x);
return ieee754sp_nanxcpt(y, "neg");
}
-
- if (ieee754sp_isnan(x)) /* but not infinity */
- return ieee754sp_nanxcpt(x, "neg", x);
return x;
}
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] Fix absd emulation
2009-07-10 8:50 [PATCH] Fix absd emulation Raghu Gandham
@ 2009-10-12 16:15 ` Ralf Baechle
2009-10-12 21:57 ` Chris Dearman
0 siblings, 1 reply; 11+ messages in thread
From: Ralf Baechle @ 2009-10-12 16:15 UTC (permalink / raw)
To: Raghu Gandham; +Cc: linux-mips, chris
On Fri, Jul 10, 2009 at 01:50:58AM -0700, Raghu Gandham wrote:
> From: Robin Randhawa <robin@mips.com>
>
> Signed-off-by: Chris Dearman <chris@mips.com>
> ---
>
> arch/mips/math-emu/dp_simple.c | 11 ++++-------
> arch/mips/math-emu/sp_simple.c | 3 ---
> 2 files changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/arch/mips/math-emu/dp_simple.c b/arch/mips/math-emu/dp_simple.c
> index 1c555e6..6ff4655 100644
> --- a/arch/mips/math-emu/dp_simple.c
> +++ b/arch/mips/math-emu/dp_simple.c
> @@ -76,15 +76,12 @@ ieee754dp ieee754dp_abs(ieee754dp x)
> CLEARCX;
> FLUSHXDP;
>
> + /* Clear sign ALWAYS, irrespective of NaN */
> + DPSIGN(x) = 0;
> +
> if (xc == IEEE754_CLASS_SNAN) {
> SETCX(IEEE754_INVALID_OPERATION);
> - return ieee754dp_nanxcpt(ieee754dp_indef(), "neg");
> + return ieee754dp_nanxcpt(ieee754dp_indef(), "abs");
> }
> -
> - if (ieee754dp_isnan(x)) /* but not infinity */
> - return ieee754dp_nanxcpt(x, "abs", x);
> -
> - /* quick fix up */
> - DPSIGN(x) = 0;
> return x;
> }
It seems that abs.s needs the same changes except the string constant. Or
why was only abs.d changed?
(And what is the official behaviour anyway. It seems I can spend another
quality night over IEEE 754 ...)
> diff --git a/arch/mips/math-emu/sp_simple.c b/arch/mips/math-emu/sp_simple.c
> index 770f0f4..cdec1a2 100644
> --- a/arch/mips/math-emu/sp_simple.c
> +++ b/arch/mips/math-emu/sp_simple.c
> @@ -61,9 +61,6 @@ ieee754sp ieee754sp_neg(ieee754sp x)
> SPSIGN(y) = SPSIGN(x);
> return ieee754sp_nanxcpt(y, "neg");
> }
> -
> - if (ieee754sp_isnan(x)) /* but not infinity */
> - return ieee754sp_nanxcpt(x, "neg", x);
> return x;
> }
The subject of the patch was claiming a fix to abs.d but this is fiddling
with neg.s. And why not the equivalent change to neg.d?
Ralf
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Fix absd emulation
2009-10-12 16:15 ` Ralf Baechle
@ 2009-10-12 21:57 ` Chris Dearman
2009-10-12 21:57 ` [PATCH] Fix abs.[sd] and neg.[sd] emulation for NaN operands Chris Dearman
0 siblings, 1 reply; 11+ messages in thread
From: Chris Dearman @ 2009-10-12 21:57 UTC (permalink / raw)
To: linux-mips
It seems like the original patch got mangled somewhere along the line. It
should correct the behaviour of abs.[sd] and neg.[sd]. I'll repost the
correct patch.
Chris
--
Chris Dearman Desk: +1 408 530 5092 Cell: +1 650 224 8603
MIPS Technologies Inc 955 East Arques Ave, Sunnyvale CA 94085
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] Fix abs.[sd] and neg.[sd] emulation for NaN operands
2009-10-12 21:57 ` Chris Dearman
@ 2009-10-12 21:57 ` Chris Dearman
2010-05-10 14:49 ` Atsushi Nemoto
0 siblings, 1 reply; 11+ messages in thread
From: Chris Dearman @ 2009-10-12 21:57 UTC (permalink / raw)
To: linux-mips
From: Nigel Stephens <nigel@mips.com>
This patch ensures that the sign bit is always updated
for NaN operands.
Signed-off-by: Chris Dearman <chris@mips.com>
---
arch/mips/math-emu/dp_simple.c | 13 ++++---------
arch/mips/math-emu/sp_simple.c | 11 +++--------
2 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/arch/mips/math-emu/dp_simple.c b/arch/mips/math-emu/dp_simple.c
index 1c555e6..d9ae1db 100644
--- a/arch/mips/math-emu/dp_simple.c
+++ b/arch/mips/math-emu/dp_simple.c
@@ -62,8 +62,6 @@ ieee754dp ieee754dp_neg(ieee754dp x)
return ieee754dp_nanxcpt(y, "neg");
}
- if (ieee754dp_isnan(x)) /* but not infinity */
- return ieee754dp_nanxcpt(x, "neg", x);
return x;
}
@@ -76,15 +74,12 @@ ieee754dp ieee754dp_abs(ieee754dp x)
CLEARCX;
FLUSHXDP;
+ /* Clear sign ALWAYS, irrespective of NaN */
+ DPSIGN(x) = 0;
+
if (xc == IEEE754_CLASS_SNAN) {
- SETCX(IEEE754_INVALID_OPERATION);
- return ieee754dp_nanxcpt(ieee754dp_indef(), "neg");
+ return ieee754dp_nanxcpt(ieee754dp_indef(), "abs");
}
- if (ieee754dp_isnan(x)) /* but not infinity */
- return ieee754dp_nanxcpt(x, "abs", x);
-
- /* quick fix up */
- DPSIGN(x) = 0;
return x;
}
diff --git a/arch/mips/math-emu/sp_simple.c b/arch/mips/math-emu/sp_simple.c
index 770f0f4..3175477 100644
--- a/arch/mips/math-emu/sp_simple.c
+++ b/arch/mips/math-emu/sp_simple.c
@@ -62,8 +62,6 @@ ieee754sp ieee754sp_neg(ieee754sp x)
return ieee754sp_nanxcpt(y, "neg");
}
- if (ieee754sp_isnan(x)) /* but not infinity */
- return ieee754sp_nanxcpt(x, "neg", x);
return x;
}
@@ -76,15 +74,12 @@ ieee754sp ieee754sp_abs(ieee754sp x)
CLEARCX;
FLUSHXSP;
+ /* Clear sign ALWAYS, irrespective of NaN */
+ SPSIGN(x) = 0;
+
if (xc == IEEE754_CLASS_SNAN) {
- SETCX(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "abs");
}
- if (ieee754sp_isnan(x)) /* but not infinity */
- return ieee754sp_nanxcpt(x, "abs", x);
-
- /* quick fix up */
- SPSIGN(x) = 0;
return x;
}
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] Fix abs.[sd] and neg.[sd] emulation for NaN operands
2009-10-12 21:57 ` [PATCH] Fix abs.[sd] and neg.[sd] emulation for NaN operands Chris Dearman
@ 2010-05-10 14:49 ` Atsushi Nemoto
2010-05-10 18:37 ` Chris Dearman
0 siblings, 1 reply; 11+ messages in thread
From: Atsushi Nemoto @ 2010-05-10 14:49 UTC (permalink / raw)
To: chris; +Cc: linux-mips
Excuse me for too late comment.
On Mon, 12 Oct 2009 14:57:18 -0700, Chris Dearman <chris@mips.com> wrote:
> From: Nigel Stephens <nigel@mips.com>
>
> This patch ensures that the sign bit is always updated
> for NaN operands.
...
> @@ -76,15 +74,12 @@ ieee754dp ieee754dp_abs(ieee754dp x)
> CLEARCX;
> FLUSHXDP;
>
> + /* Clear sign ALWAYS, irrespective of NaN */
> + DPSIGN(x) = 0;
> +
> if (xc == IEEE754_CLASS_SNAN) {
> - SETCX(IEEE754_INVALID_OPERATION);
> - return ieee754dp_nanxcpt(ieee754dp_indef(), "neg");
> + return ieee754dp_nanxcpt(ieee754dp_indef(), "abs");
> }
>
> - if (ieee754dp_isnan(x)) /* but not infinity */
> - return ieee754dp_nanxcpt(x, "abs", x);
> -
> - /* quick fix up */
> - DPSIGN(x) = 0;
> return x;
> }
Is there any reason for removal of SETCX(IEEE754_INVALID_OPERATION)
line here?
The older version of this fix ("Fix absd emulation" by Raghu Gandham)
did not remove the line.
Without this line, a signaling NaN will not raise a signal. It seems
not expected behaviour.
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Fix abs.[sd] and neg.[sd] emulation for NaN operands
2010-05-10 14:49 ` Atsushi Nemoto
@ 2010-05-10 18:37 ` Chris Dearman
2010-05-11 15:45 ` Atsushi Nemoto
0 siblings, 1 reply; 11+ messages in thread
From: Chris Dearman @ 2010-05-10 18:37 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: linux-mips
Atsushi Nemoto wrote:
> Excuse me for too late comment.
>
> On Mon, 12 Oct 2009 14:57:18 -0700, Chris Dearman <chris@mips.com> wrote:
>> From: Nigel Stephens <nigel@mips.com>
>>
>> This patch ensures that the sign bit is always updated
>> for NaN operands.
> ...
>> @@ -76,15 +74,12 @@ ieee754dp ieee754dp_abs(ieee754dp x)
>> CLEARCX;
>> FLUSHXDP;
>>
>> + /* Clear sign ALWAYS, irrespective of NaN */
>> + DPSIGN(x) = 0;
>> +
>> if (xc == IEEE754_CLASS_SNAN) {
>> - SETCX(IEEE754_INVALID_OPERATION);
>> - return ieee754dp_nanxcpt(ieee754dp_indef(), "neg");
>> + return ieee754dp_nanxcpt(ieee754dp_indef(), "abs");
>> }
>>
>> - if (ieee754dp_isnan(x)) /* but not infinity */
>> - return ieee754dp_nanxcpt(x, "abs", x);
>> -
>> - /* quick fix up */
>> - DPSIGN(x) = 0;
>> return x;
>> }
>
> Is there any reason for removal of SETCX(IEEE754_INVALID_OPERATION)
> line here?
>
> The older version of this fix ("Fix absd emulation" by Raghu Gandham)
> did not remove the line.
>
> Without this line, a signaling NaN will not raise a signal. It seems
> not expected behaviour.
ieee754dp/sp_nanxcpt also sets the invalid exception bit so I think this
is duplicated code. I think the same fix should have been applied to
ieee754sp_neg/ieee754dp_neg for consistency.
Chris
--
Chris Dearman Desk: +1 408 530 5092 Cell: +1 408 398 5531
MIPS Technologies Inc 955 East Arques Ave, Sunnyvale CA 94085
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Fix abs.[sd] and neg.[sd] emulation for NaN operands
2010-05-10 18:37 ` Chris Dearman
@ 2010-05-11 15:45 ` Atsushi Nemoto
2010-05-12 1:30 ` Chris Dearman
2010-05-12 1:30 ` [PATCH] Restore signalling NaN behaviour for abs.[sd] Chris Dearman
0 siblings, 2 replies; 11+ messages in thread
From: Atsushi Nemoto @ 2010-05-11 15:45 UTC (permalink / raw)
To: chris; +Cc: linux-mips
On Mon, 10 May 2010 11:37:10 -0700, Chris Dearman <chris@mips.com> wrote:
> >> if (xc == IEEE754_CLASS_SNAN) {
> >> - SETCX(IEEE754_INVALID_OPERATION);
> >> - return ieee754dp_nanxcpt(ieee754dp_indef(), "neg");
> >> + return ieee754dp_nanxcpt(ieee754dp_indef(), "abs");
> >> }
...
> ieee754dp/sp_nanxcpt also sets the invalid exception bit so I think this
> is duplicated code. I think the same fix should have been applied to
> ieee754sp_neg/ieee754dp_neg for consistency.
ieee754d/sp_nanxcpt will set the invalid exception bit if its first
argument was a signaling NaN. And ieee754dp/sp_indef() is a quiet
NaN.
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Fix abs.[sd] and neg.[sd] emulation for NaN operands
2010-05-11 15:45 ` Atsushi Nemoto
@ 2010-05-12 1:30 ` Chris Dearman
2010-05-12 1:30 ` [PATCH] Restore signalling NaN behaviour for abs.[sd] Chris Dearman
1 sibling, 0 replies; 11+ messages in thread
From: Chris Dearman @ 2010-05-12 1:30 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: linux-mips
Atsushi Nemoto wrote:
>
> ieee754d/sp_nanxcpt will set the invalid exception bit if its first
> argument was a signaling NaN. And ieee754dp/sp_indef() is a quiet
> NaN.
You're right! I'll send a separate patch with an appropriate subject to
correct this.
Thanks
Chris
--
Chris Dearman Desk: +1 408 530 5092 Cell: +1 408 398 5531
MIPS Technologies Inc 955 East Arques Ave, Sunnyvale CA 94085
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] Restore signalling NaN behaviour for abs.[sd]
2010-05-11 15:45 ` Atsushi Nemoto
2010-05-12 1:30 ` Chris Dearman
@ 2010-05-12 1:30 ` Chris Dearman
2010-05-14 4:48 ` Atsushi Nemoto
2010-05-22 7:15 ` Ralf Baechle
1 sibling, 2 replies; 11+ messages in thread
From: Chris Dearman @ 2010-05-12 1:30 UTC (permalink / raw)
To: linux-mips
Atsushi Nemoto <anemo@mba.ocn.ne.jp> spotted that this had been
incorrectly removed in a previous patch
Signed-off-by: Chris Dearman <chris@mips.com>
---
arch/mips/math-emu/dp_simple.c | 1 +
arch/mips/math-emu/sp_simple.c | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/arch/mips/math-emu/dp_simple.c b/arch/mips/math-emu/dp_simple.c
index d9ae1db..b909742 100644
--- a/arch/mips/math-emu/dp_simple.c
+++ b/arch/mips/math-emu/dp_simple.c
@@ -78,6 +78,7 @@ ieee754dp ieee754dp_abs(ieee754dp x)
DPSIGN(x) = 0;
if (xc == IEEE754_CLASS_SNAN) {
+ SETCX(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "abs");
}
diff --git a/arch/mips/math-emu/sp_simple.c b/arch/mips/math-emu/sp_simple.c
index 3175477..2fd53c9 100644
--- a/arch/mips/math-emu/sp_simple.c
+++ b/arch/mips/math-emu/sp_simple.c
@@ -78,6 +78,7 @@ ieee754sp ieee754sp_abs(ieee754sp x)
SPSIGN(x) = 0;
if (xc == IEEE754_CLASS_SNAN) {
+ SETCX(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "abs");
}
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] Restore signalling NaN behaviour for abs.[sd]
2010-05-12 1:30 ` [PATCH] Restore signalling NaN behaviour for abs.[sd] Chris Dearman
@ 2010-05-14 4:48 ` Atsushi Nemoto
2010-05-22 7:15 ` Ralf Baechle
1 sibling, 0 replies; 11+ messages in thread
From: Atsushi Nemoto @ 2010-05-14 4:48 UTC (permalink / raw)
To: chris; +Cc: linux-mips
On Tue, 11 May 2010 18:30:34 -0700, Chris Dearman <chris@mips.com> wrote:
> Atsushi Nemoto <anemo@mba.ocn.ne.jp> spotted that this had been
> incorrectly removed in a previous patch
>
> Signed-off-by: Chris Dearman <chris@mips.com>
Thanks!
Tested-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Restore signalling NaN behaviour for abs.[sd]
2010-05-12 1:30 ` [PATCH] Restore signalling NaN behaviour for abs.[sd] Chris Dearman
2010-05-14 4:48 ` Atsushi Nemoto
@ 2010-05-22 7:15 ` Ralf Baechle
1 sibling, 0 replies; 11+ messages in thread
From: Ralf Baechle @ 2010-05-22 7:15 UTC (permalink / raw)
To: Chris Dearman; +Cc: linux-mips
On Tue, May 11, 2010 at 06:30:34PM -0700, Chris Dearman wrote:
Thanks, applied.
Ralf
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2010-05-22 7:15 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-10 8:50 [PATCH] Fix absd emulation Raghu Gandham
2009-10-12 16:15 ` Ralf Baechle
2009-10-12 21:57 ` Chris Dearman
2009-10-12 21:57 ` [PATCH] Fix abs.[sd] and neg.[sd] emulation for NaN operands Chris Dearman
2010-05-10 14:49 ` Atsushi Nemoto
2010-05-10 18:37 ` Chris Dearman
2010-05-11 15:45 ` Atsushi Nemoto
2010-05-12 1:30 ` Chris Dearman
2010-05-12 1:30 ` [PATCH] Restore signalling NaN behaviour for abs.[sd] Chris Dearman
2010-05-14 4:48 ` Atsushi Nemoto
2010-05-22 7:15 ` Ralf Baechle
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.