diff options
| author | rin <rin@NetBSD.org> | 2022-09-14 05:54:07 +0000 |
|---|---|---|
| committer | rin <rin@NetBSD.org> | 2022-09-14 05:54:07 +0000 |
| commit | 0da00263efc5b72ece0e10d1def64bb276e56bd5 (patch) | |
| tree | 20bc5d10ca20475513da5807f9711db921401433 /sys | |
| parent | eba904eeceacc2aa4875ac5956e1c08fbd189943 (diff) | |
Fix logic for FPSCR[UX]:
- Correct FPSCR[FPRF] field when round to 0.0 or 0.0f.
- Simplify.
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/arch/powerpc/fpu/fpu_implode.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/sys/arch/powerpc/fpu/fpu_implode.c b/sys/arch/powerpc/fpu/fpu_implode.c index bb94143e1de..f3616f219c6 100644 --- a/sys/arch/powerpc/fpu/fpu_implode.c +++ b/sys/arch/powerpc/fpu/fpu_implode.c @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_implode.c,v 1.22 2022/09/04 13:17:33 rin Exp $ */ +/* $NetBSD: fpu_implode.c,v 1.23 2022/09/14 05:54:07 rin Exp $ */ /* * Copyright (c) 1992, 1993 @@ -46,7 +46,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fpu_implode.c,v 1.22 2022/09/04 13:17:33 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu_implode.c,v 1.23 2022/09/14 05:54:07 rin Exp $"); #include <sys/types.h> #include <sys/systm.h> @@ -397,10 +397,14 @@ fpu_ftos(struct fpemu *fe, struct fpn *fp, int *cx) *cx |= FPRF_SIGN(sign); return (sign | SNG_EXP(1) | 0); } - *cx |= FPSCR_C | FPRF_SIGN(sign); - if (((fe->fe_cx | *cx) & FPSCR_FI) || - (fe->fe_fpscr & FPSCR_UX)) + if (*cx & FPSCR_FI) { *cx |= FPSCR_UX; + if (fp->fp_mant[3] == 0) { + *cx |= FPSCR_FE; + return sign; + } + } + *cx |= FPSCR_C | FPRF_SIGN(sign); return (sign | SNG_EXP(0) | fp->fp_mant[3]); } /* -FP_NG for g,r; -1 for implied 1; -SNG_FRACBITS for fraction */ @@ -466,10 +470,15 @@ fpu_ftod(struct fpemu *fe, struct fpn *fp, int *cx) *cx |= FPRF_SIGN(sign); return HI_WORD(sign | DBL_EXP(1) | 0); } - *cx |= FPSCR_C | FPRF_SIGN(sign); - if (((fe->fe_cx | *cx) & FPSCR_FI) || - (fe->fe_fpscr & FPSCR_UX)) + if (*cx & FPSCR_FI) { *cx |= FPSCR_UX; + if ((fp->fp_mant[2] & DBL_MASK) == 0 && + fp->fp_mant[3] == 0) { + *cx |= FPSCR_FE; + return HI_WORD(sign); + } + } + *cx |= FPSCR_C | FPRF_SIGN(sign); exp = 0; goto done; } |
