Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/powerpc/fpu Fix fsel; frB is chosen when frA is neg...



details:   https://anonhg.NetBSD.org/src/rev/ad08d001eb1e
branches:  trunk
changeset: 369749:ad08d001eb1e
user:      rin <rin%NetBSD.org@localhost>
date:      Tue Aug 30 10:59:43 2022 +0000

description:
Fix fsel; frB is chosen when frA is negative or NaN.

For fpu_emu.c rev 1.41 or prior, wrong register was chosen for
NaN with sign bit being cleared.

diffstat:

 sys/arch/powerpc/fpu/fpu_emu.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (34 lines):

diff -r 3be904053af4 -r ad08d001eb1e sys/arch/powerpc/fpu/fpu_emu.c
--- a/sys/arch/powerpc/fpu/fpu_emu.c    Tue Aug 30 10:55:06 2022 +0000
+++ b/sys/arch/powerpc/fpu/fpu_emu.c    Tue Aug 30 10:59:43 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu_emu.c,v 1.41 2022/08/30 10:55:06 rin Exp $ */
+/*     $NetBSD: fpu_emu.c,v 1.42 2022/08/30 10:59:43 rin Exp $ */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu_emu.c,v 1.41 2022/08/30 10:55:06 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu_emu.c,v 1.42 2022/08/30 10:59:43 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -670,9 +670,13 @@
                                FPU_EMU_EVCNT_INCR(fsel);
                                DPRINTF(FPE_INSN, ("fpu_execute: FSEL\n"));
                                a = (int *)&fe->fe_fpstate->fpreg[ra];
-                               if ((*a & 0x80000000) && (*a & 0x7fffffff)) 
-                                       /* fra < 0 */
+                               if ((( a[0] & 0x80000000) &&
+                                    ((a[0] & 0x7fffffff) | a[1])) ||
+                                   (( a[0] & 0x7ff00000) &&
+                                    ((a[0] & 0x000fffff) | a[1]))) {
+                                       /* negative/NaN or NaN */
                                        rc = rb;
+                               }
                                DPRINTF(FPE_INSN, ("f%d => f%d\n", rc, rt));
                                memcpy(&fs->fpreg[rt], &fs->fpreg[rc],
                                        sizeof(double));



Home | Main Index | Thread Index | Old Index