diff options
| author | Nigel Stephens <nigel@mips.com> | 2009-10-12 17:57:18 -0400 |
|---|---|---|
| committer | Ralf Baechle <ralf@linux-mips.org> | 2009-11-02 06:00:05 -0500 |
| commit | cea2be444380fc1bf665cd023ed84be7e0872d28 (patch) | |
| tree | 9e477926a9c67f143a7d44ad89a2cdf2a37dc041 | |
| parent | a074f0e89faa8989bdbd6110785d2aafe7df5285 (diff) | |
MIPS: Fix abs.[sd] and neg.[sd] emulation for NaN operands
This patch ensures that the sign bit is always updated for NaN operands.
Signed-off-by: Chris Dearman <chris@mips.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
| -rw-r--r-- | arch/mips/math-emu/dp_simple.c | 13 | ||||
| -rw-r--r-- | 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 1c555e6c6a9f..d9ae1dbabda7 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) | |||
| 62 | return ieee754dp_nanxcpt(y, "neg"); | 62 | return ieee754dp_nanxcpt(y, "neg"); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | if (ieee754dp_isnan(x)) /* but not infinity */ | ||
| 66 | return ieee754dp_nanxcpt(x, "neg", x); | ||
| 67 | return x; | 65 | return x; |
| 68 | } | 66 | } |
| 69 | 67 | ||
| @@ -76,15 +74,12 @@ ieee754dp ieee754dp_abs(ieee754dp x) | |||
| 76 | CLEARCX; | 74 | CLEARCX; |
| 77 | FLUSHXDP; | 75 | FLUSHXDP; |
| 78 | 76 | ||
| 77 | /* Clear sign ALWAYS, irrespective of NaN */ | ||
| 78 | DPSIGN(x) = 0; | ||
| 79 | |||
| 79 | if (xc == IEEE754_CLASS_SNAN) { | 80 | if (xc == IEEE754_CLASS_SNAN) { |
| 80 | SETCX(IEEE754_INVALID_OPERATION); | 81 | return ieee754dp_nanxcpt(ieee754dp_indef(), "abs"); |
| 81 | return ieee754dp_nanxcpt(ieee754dp_indef(), "neg"); | ||
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | if (ieee754dp_isnan(x)) /* but not infinity */ | ||
| 85 | return ieee754dp_nanxcpt(x, "abs", x); | ||
| 86 | |||
| 87 | /* quick fix up */ | ||
| 88 | DPSIGN(x) = 0; | ||
| 89 | return x; | 84 | return x; |
| 90 | } | 85 | } |
diff --git a/arch/mips/math-emu/sp_simple.c b/arch/mips/math-emu/sp_simple.c index 770f0f4677cd..3175477d36f6 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) | |||
| 62 | return ieee754sp_nanxcpt(y, "neg"); | 62 | return ieee754sp_nanxcpt(y, "neg"); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | if (ieee754sp_isnan(x)) /* but not infinity */ | ||
| 66 | return ieee754sp_nanxcpt(x, "neg", x); | ||
| 67 | return x; | 65 | return x; |
| 68 | } | 66 | } |
| 69 | 67 | ||
| @@ -76,15 +74,12 @@ ieee754sp ieee754sp_abs(ieee754sp x) | |||
| 76 | CLEARCX; | 74 | CLEARCX; |
| 77 | FLUSHXSP; | 75 | FLUSHXSP; |
| 78 | 76 | ||
| 77 | /* Clear sign ALWAYS, irrespective of NaN */ | ||
| 78 | SPSIGN(x) = 0; | ||
| 79 | |||
| 79 | if (xc == IEEE754_CLASS_SNAN) { | 80 | if (xc == IEEE754_CLASS_SNAN) { |
| 80 | SETCX(IEEE754_INVALID_OPERATION); | ||
| 81 | return ieee754sp_nanxcpt(ieee754sp_indef(), "abs"); | 81 | return ieee754sp_nanxcpt(ieee754sp_indef(), "abs"); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | if (ieee754sp_isnan(x)) /* but not infinity */ | ||
| 85 | return ieee754sp_nanxcpt(x, "abs", x); | ||
| 86 | |||
| 87 | /* quick fix up */ | ||
| 88 | SPSIGN(x) = 0; | ||
| 89 | return x; | 84 | return x; |
| 90 | } | 85 | } |
