Fix absd emulation
PATCH 1/1 Fix absd emulation
From: Robin Randhawa <[email protected]>
---
arch/mips/math-emu/dp_simple.c | 11 ++++------- arch/mips/math-emu/sp_simple.c | 3 --- 2 files changed, 4 insertions(+), 10 deletions(-)
arch/mips/math-emu/dp_simple.c +4 -7
@@ -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; }
arch/mips/math-emu/sp_simple.c +0 -3
@@ -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; }
Quoted 23 lines · Raghu Gandham
From: Robin Randhawa <[email protected]>
Signed-off-by Chris Dearman <[email protected]>---
arch/mips/math-emu/dp_simple.c | 11 ++++------- arch/mips/math-emu/sp_simple.c | 3 --- 2 files changed, 4 insertions(+), 10 deletions(-)arch/mips/math-emu/dp_simple.c +3
-1@@ -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" );
arch/mips/math-emu/dp_simple.c ieee754dp ieee754dp_abs(ieee754dp x) · line 87
Quoted 10 lines
arch/mips/math-emu/dp_simple.c +1
-6+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 ...)
arch/mips/math-emu/sp_simple.c ieee754sp ieee754sp_neg(ieee754sp x) · line 65
Quoted 13 lines
arch/mips/math-emu/sp_simple.c +0
-3@@ -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
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
Signature · 2 lines
Chris Dearman Desk: +1 408 530 5092 Cell: +1 650 224 8603 MIPS Technologies Inc 955 East Arques Ave, Sunnyvale CA 94085
PATCH 1/1 Fix abs.[sd] and neg.[sd] emulation for NaN operands
From: Nigel Stephens <[email protected]>
This patch ensures that the sign bit is always updated for NaN operands.
---
arch/mips/math-emu/dp_simple.c | 13 ++++--------- arch/mips/math-emu/sp_simple.c | 11 +++-------- 2 files changed, 7 insertions(+), 17 deletions(-)
arch/mips/math-emu/dp_simple.c +4 -9
@@ -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; }
arch/mips/math-emu/sp_simple.c +3 -8
@@ -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; }
Re: [PATCH] Fix abs.[sd] and neg.[sd] emulation for NaN operands
Excuse me for too late comment.
Quoted 4 lines · Chris Dearman
From: Nigel Stephens <[email protected]>
This patch ensures that the sign bit is always updated for NaN operands.
...
Quoted 10 lines
arch/mips/math-emu/dp_simple.c +3
-2@@ -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" );
arch/mips/math-emu/dp_simple.c ieee754dp ieee754dp_abs(ieee754dp x) · line 85
Quoted 10 lines
arch/mips/math-emu/dp_simple.c +1
-5+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
Re: [PATCH] Fix abs.[sd] and neg.[sd] emulation for NaN operands
Quoted 32 lines · Atsushi Nemoto
Excuse me for too late comment.
Quoted 4 lines · Chris Dearman
From: Nigel Stephens <[email protected]>
This patch ensures that the sign bit is always updated for NaN operands.
...
Quoted 10 lines
arch/mips/math-emu/dp_simple.c +3
-2@@ -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" );arch/mips/math-emu/dp_simple.c ieee754dp ieee754dp_abs(ieee754dp x) · line 85
Quoted 10 lines
arch/mips/math-emu/dp_simple.c +1
-5+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?
Quoted 5 lines
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
Signature · 2 lines
Chris Dearman Desk: +1 408 530 5092 Cell: +1 408 398 5531 MIPS Technologies Inc 955 East Arques Ave, Sunnyvale CA 94085
Re: [PATCH] Fix abs.[sd] and neg.[sd] emulation for NaN operands
Quoted 5 lines · Chris Dearman
Quoted 5 lines
Quoted 5 lines
arch/mips/math-emu/dp_simple.c +1
-2if (xc ==IEEE754_CLASS_SNAN ) { -SETCX (IEEE754_INVALID_OPERATION ); -return ieee754dp_nanxcpt (ieee754dp_indef (),"neg" ); +return ieee754dp_nanxcpt (ieee754dp_indef (),"abs" ); }
...
Quoted 3 lines
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
Re: [PATCH] Fix abs.[sd] and neg.[sd] emulation for NaN operands
Quoted 4 lines · Atsushi Nemoto
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
Signature · 2 lines
Chris Dearman Desk: +1 408 530 5092 Cell: +1 408 398 5531 MIPS Technologies Inc 955 East Arques Ave, Sunnyvale CA 94085
PATCH 1/1 Restore signalling NaN behaviour for abs.[sd]
In reply to Atsushi NemotoAtsushi Nemoto <[email protected]> spotted that this had been incorrectly removed in a previous patch
---
arch/mips/math-emu/dp_simple.c | 1 + arch/mips/math-emu/sp_simple.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
arch/mips/math-emu/dp_simple.c +1 -0
@@ -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" ); }
arch/mips/math-emu/sp_simple.c +1 -0
@@ -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" ); }
Re: [PATCH] Restore signalling NaN behaviour for abs.[sd]
Quoted 4 lines · Chris Dearman
Atsushi Nemoto <[email protected]> spotted that this had been incorrectly removed in a previous patch
Signed-off-by Chris Dearman <[email protected]>
Thanks!
Ralf Baechle
AppliedRe: [PATCH] Restore signalling NaN behaviour for abs.[sd]
In reply to Chris DearmanOn Tue, May 11, 2010 at 06:30:34PM -0700, Chris Dearman wrote:
Thanks, applied.
Ralf