diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2007-12-25 15:47:17 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2007-12-25 15:47:17 +0000 |
commit | 3ab4649aaa0adba5922c264dbaabb4befb93a53d (patch) | |
tree | 35a84fc51faed43a4b6b7a413e5a8b69c1237159 /sys/arch | |
parent | d3517d1383db5e4d5fd27700b779618767d1b744 (diff) |
A few fixes in the exception bits reporting, spotted by John Hauser's TestFloat.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/m88k/fpu/fpu_compare.c | 6 | ||||
-rw-r--r-- | sys/arch/m88k/fpu/fpu_implode.c | 14 | ||||
-rw-r--r-- | sys/arch/m88k/fpu/fpu_mul.c | 4 |
3 files changed, 14 insertions, 10 deletions
diff --git a/sys/arch/m88k/fpu/fpu_compare.c b/sys/arch/m88k/fpu/fpu_compare.c index 061216353b0..16472c79de5 100644 --- a/sys/arch/m88k/fpu/fpu_compare.c +++ b/sys/arch/m88k/fpu/fpu_compare.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpu_compare.c,v 1.1 2007/12/25 00:29:49 miod Exp $ */ +/* $OpenBSD: fpu_compare.c,v 1.2 2007/12/25 15:47:16 miod Exp $ */ /* * Copyright (c) 2007 Miodrag Vallat. @@ -100,13 +100,13 @@ fpu_compare(struct fpemu *fe, int fcmpu) /* fcmpu shall only raise an exception for signalling NaNs */ if (ISNAN(a)) { - if (fcmpu || (a->fp_mant[0] & FP_QUIETBIT) != 0) + if (!fcmpu || (a->fp_mant[0] & FP_QUIETBIT) != 0) fe->fe_fpsr |= FPSR_EFINV; cc = CC_UN; goto done; } if (ISNAN(b)) { - if (fcmpu || (b->fp_mant[0] & FP_QUIETBIT) != 0) + if (!fcmpu || (b->fp_mant[0] & FP_QUIETBIT) != 0) fe->fe_fpsr |= FPSR_EFINV; cc = CC_UN; goto done; diff --git a/sys/arch/m88k/fpu/fpu_implode.c b/sys/arch/m88k/fpu/fpu_implode.c index c653c39adae..a2cfe2d8835 100644 --- a/sys/arch/m88k/fpu/fpu_implode.c +++ b/sys/arch/m88k/fpu/fpu_implode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpu_implode.c,v 1.1 2007/12/25 00:29:49 miod Exp $ */ +/* $OpenBSD: fpu_implode.c,v 1.2 2007/12/25 15:47:16 miod Exp $ */ /* * Copyright (c) 1992, 1993 @@ -267,7 +267,8 @@ fpu_ftos(struct fpemu *fe, struct fpn *fp) * right to introduce leading zeroes. Rounding then acts * differently for normals and subnormals: the largest subnormal * may round to the smallest normal (1.0 x 2^minexp), or may - * remain subnormal. In the latter case, signal an underflow. + * remain subnormal. In the latter case, signal an underflow + * if the result was inexact. * * Rounding a normal, on the other hand, always produces another * normal (although either way the result might be too big for @@ -284,7 +285,8 @@ fpu_ftos(struct fpemu *fe, struct fpn *fp) (void) fpu_shr(fp, FP_NMANT - FP_NG - SNG_FRACBITS - exp); if (round(fe, fp) && fp->fp_mant[3] == SNG_EXP(1)) return (sign | SNG_EXP(1) | 0); - fe->fe_fpsr |= FPSR_EFUNF; + if (fe->fe_fpsr & FPSR_EFINX) + fe->fe_fpsr |= FPSR_EFUNF; return (sign | SNG_EXP(0) | fp->fp_mant[3]); } /* -FP_NG for g,r; -1 for implied 1; -SNG_FRACBITS for fraction */ @@ -342,7 +344,8 @@ zero: res[1] = 0; res[1] = 0; return (sign | DBL_EXP(1) | 0); } - fe->fe_fpsr |= FPSR_EFUNF; + if (fe->fe_fpsr & FPSR_EFINX) + fe->fe_fpsr |= FPSR_EFUNF; exp = 0; goto done; } @@ -399,8 +402,7 @@ zero: res[1] = res[2] = res[3] = 0; res[1] = res[2] = res[3] = 0; return (sign | EXT_EXP(1) | 0); } - if ((fe->fe_fpsr & FPSR_EFINX) || - (fe->fe_fpcr & FPSR_EFUNF)) + if (fe->fe_fpsr & FPSR_EFINX) fe->fe_fpsr |= FPSR_EFUNF; exp = 0; goto done; diff --git a/sys/arch/m88k/fpu/fpu_mul.c b/sys/arch/m88k/fpu/fpu_mul.c index 7bc36a56907..50e5d13b625 100644 --- a/sys/arch/m88k/fpu/fpu_mul.c +++ b/sys/arch/m88k/fpu/fpu_mul.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpu_mul.c,v 1.1 2007/12/25 00:29:49 miod Exp $ */ +/* $OpenBSD: fpu_mul.c,v 1.2 2007/12/25 15:47:16 miod Exp $ */ /* * Copyright (c) 1992, 1993 @@ -46,6 +46,7 @@ #include <sys/types.h> +#include <machine/fpu.h> #include <machine/frame.h> #include <m88k/fpu/fpu_arith.h> @@ -122,6 +123,7 @@ fpu_mul(struct fpemu *fe) ORDER(x, y); if (ISNAN(y)) { y->fp_sign ^= x->fp_sign; + fe->fe_fpsr |= FPSR_EFINV; return (y); } if (ISINF(y)) { |