Source-Changes-HG archive

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

[src/netbsd-1-4]: src/sys/arch/m68k/fpe pullup 1.2->1.3 (briggs): fix FPE



details:   https://anonhg.NetBSD.org/src/rev/919026070c89
branches:  netbsd-1-4
changeset: 468811:919026070c89
user:      perry <perry%NetBSD.org@localhost>
date:      Mon Jun 21 15:21:24 1999 +0000

description:
pullup 1.2->1.3 (briggs): fix FPE

diffstat:

 sys/arch/m68k/fpe/fpu_subr.c |  75 +++++++++++++++++++------------------------
 1 files changed, 34 insertions(+), 41 deletions(-)

diffs (179 lines):

diff -r 1eca4fcd5916 -r 919026070c89 sys/arch/m68k/fpe/fpu_subr.c
--- a/sys/arch/m68k/fpe/fpu_subr.c      Mon Jun 21 15:21:09 1999 +0000
+++ b/sys/arch/m68k/fpe/fpu_subr.c      Mon Jun 21 15:21:24 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu_subr.c,v 1.2 1996/04/30 11:52:38 briggs Exp $ */
+/*     $NetBSD: fpu_subr.c,v 1.2.24.1 1999/06/21 15:21:24 perry Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -65,31 +65,29 @@
 int
 fpu_shr(register struct fpn *fp, register int rsh)
 {
-       register u_int m0, m1, m2, m3, s;
+       register u_int m0, m1, m2, s;
        register int lsh;
 
 #ifdef DIAGNOSTIC
-       if (rsh <= 0 || (fp->fp_class != FPC_NUM && !ISNAN(fp)))
+       if (rsh < 0 || (fp->fp_class != FPC_NUM && !ISNAN(fp)))
                panic("fpu_rightshift 1");
 #endif
 
        m0 = fp->fp_mant[0];
        m1 = fp->fp_mant[1];
        m2 = fp->fp_mant[2];
-       m3 = fp->fp_mant[3];
 
        /* If shifting all the bits out, take a shortcut. */
        if (rsh >= FP_NMANT) {
 #ifdef DIAGNOSTIC
-               if ((m0 | m1 | m2 | m3) == 0)
+               if ((m0 | m1 | m2) == 0)
                        panic("fpu_rightshift 2");
 #endif
                fp->fp_mant[0] = 0;
                fp->fp_mant[1] = 0;
                fp->fp_mant[2] = 0;
-               fp->fp_mant[3] = 0;
 #ifdef notdef
-               if ((m0 | m1 | m2 | m3) == 0)
+               if ((m0 | m1 | m2) == 0)
                        fp->fp_class = FPC_ZERO;
                else
 #endif
@@ -99,22 +97,18 @@
 
        /* Squish out full words. */
        s = fp->fp_sticky;
-       if (rsh >= 32 * 3) {
-               s |= m3 | m2 | m1;
-               m3 = m0, m2 = 0, m1 = 0, m0 = 0;
-       } else if (rsh >= 32 * 2) {
-               s |= m3 | m2;
-               m3 = m1, m2 = m0, m1 = 0, m0 = 0;
+       if (rsh >= 32 * 2) {
+               s |= m2 | m1;
+               m2 = m0, m1 = 0, m0 = 0;
        } else if (rsh >= 32) {
-               s |= m3;
-               m3 = m2, m2 = m1, m1 = m0, m0 = 0;
+               s |= m2;
+               m2 = m1, m1 = m0, m0 = 0;
        }
 
        /* Handle any remaining partial word. */
        if ((rsh &= 31) != 0) {
                lsh = 32 - rsh;
-               s |= m3 << lsh;
-               m3 = (m3 >> rsh) | (m2 << lsh);
+               s |= m2 << lsh;
                m2 = (m2 >> rsh) | (m1 << lsh);
                m1 = (m1 >> rsh) | (m0 << lsh);
                m0 >>= rsh;
@@ -122,7 +116,6 @@
        fp->fp_mant[0] = m0;
        fp->fp_mant[1] = m1;
        fp->fp_mant[2] = m2;
-       fp->fp_mant[3] = m3;
        fp->fp_sticky = s;
        return (s);
 }
@@ -134,29 +127,32 @@
  *
  * Internally, this may use a `supernormal' -- a number whose fp_mant
  * is greater than or equal to 2.0 -- so as a side effect you can hand it
- * a supernormal and it will fix it (provided fp->fp_mant[3] == 0).
+ * a supernormal and it will fix it (provided fp->fp_mant[2] == 0).
  */
 void
 fpu_norm(register struct fpn *fp)
 {
-       register u_int m0, m1, m2, m3, top, sup, nrm;
+       register u_int m0, m1, m2, sup, nrm;
        register int lsh, rsh, exp;
 
        exp = fp->fp_exp;
        m0 = fp->fp_mant[0];
        m1 = fp->fp_mant[1];
        m2 = fp->fp_mant[2];
-       m3 = fp->fp_mant[3];
 
        /* Handle severe subnormals with 32-bit moves. */
        if (m0 == 0) {
-               if (m1)
-                       m0 = m1, m1 = m2, m2 = m3, m3 = 0, exp -= 32;
-               else if (m2)
-                       m0 = m2, m1 = m3, m2 = 0, m3 = 0, exp -= 2 * 32;
-               else if (m3)
-                       m0 = m3, m1 = 0, m2 = 0, m3 = 0, exp -= 3 * 32;
-               else {
+               if (m1) {
+                       m0 = m1;
+                       m1 = m2;
+                       m2 = 0;
+                       exp -= 32;
+               } else if (m2) {
+                       m0 = m2;
+                       m1 = 0;
+                       m2 = 0;
+                       exp -= 2 * 32;
+               } else {
                        fp->fp_class = FPC_ZERO;
                        return;
                }
@@ -168,36 +164,33 @@
        if (m0 >= sup) {
                /*
                 * We have a supernormal number.  We need to shift it right.
-                * We may assume m3==0.
+                * We may assume m2==0.
                 */
-               for (rsh = 1, top = m0 >> 1; top >= sup; rsh++) /* XXX slow */
-                       top >>= 1;
+               asm volatile("bfffo %1{#0:#32},%0" : "=d"(rsh) : "g"(m0));
+               rsh = 31 - rsh - FP_LG;
                exp += rsh;
                lsh = 32 - rsh;
-               m3 = m2 << lsh;
-               m2 = (m2 >> rsh) | (m1 << lsh);
+               m2 = m1 << lsh;
                m1 = (m1 >> rsh) | (m0 << lsh);
-               m0 = top;
+               m0 = (m0 >> rsh);
        } else if (m0 < nrm) {
                /*
                 * We have a regular denorm (a subnormal number), and need
                 * to shift it left.
                 */
-               for (lsh = 1, top = m0 << 1; top < nrm; lsh++)  /* XXX slow */
-                       top <<= 1;
+               asm volatile("bfffo %1{#0:#32},%0" : "=d"(lsh) : "g"(m0));
+               lsh = FP_LG - 31 + lsh;
                exp -= lsh;
                rsh = 32 - lsh;
-               m0 = top | (m1 >> rsh);
+               m0 = (m0 << lsh) | (m1 >> rsh);
                m1 = (m1 << lsh) | (m2 >> rsh);
-               m2 = (m2 << lsh) | (m3 >> rsh);
-               m3 <<= lsh;
+               m2 <<= lsh;
        }
 
        fp->fp_exp = exp;
        fp->fp_mant[0] = m0;
        fp->fp_mant[1] = m1;
        fp->fp_mant[2] = m2;
-       fp->fp_mant[3] = m3;
 }
 
 /*
@@ -214,6 +207,6 @@
        fp->fp_class = FPC_QNAN;
        fp->fp_sign = 0;
        fp->fp_mant[0] = FP_1 - 1;
-       fp->fp_mant[1] = fp->fp_mant[2] = fp->fp_mant[3] = ~0;
+       fp->fp_mant[1] = fp->fp_mant[2] = ~0;
        return (fp);
 }



Home | Main Index | Thread Index | Old Index