diff options
author | Paul Brook <paul@codesourcery.com> | 2005-09-28 22:12:55 +0000 |
---|---|---|
committer | Paul Brook <pbrook@gcc.gnu.org> | 2005-09-28 22:12:55 +0000 |
commit | 107bcc113333f47bc389c0e7bca28671fa8874ff (patch) | |
tree | ac3fa726b8acb3d936603df656ceeab21b0498c3 /gcc/config/m68k/fpgnulib.c | |
parent | e7d15badcc90ce5325021cd2db72a795255e1b59 (diff) | |
download | gcc-107bcc113333f47bc389c0e7bca28671fa8874ff.zip gcc-107bcc113333f47bc389c0e7bca28671fa8874ff.tar.gz gcc-107bcc113333f47bc389c0e7bca28671fa8874ff.tar.bz2 |
fpgnulib.c (__extendsfdf2, [...]): Handle denormals.
2005-09-28 Paul Brook <paul@codesourcery.com>
* config/m68k/fpgnulib.c (__extendsfdf2, __truncdfsf2): Handle
denormals.
From-SVN: r104745
Diffstat (limited to 'gcc/config/m68k/fpgnulib.c')
-rw-r--r-- | gcc/config/m68k/fpgnulib.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/gcc/config/m68k/fpgnulib.c b/gcc/config/m68k/fpgnulib.c index f63c2be..2e8dd5d 100644 --- a/gcc/config/m68k/fpgnulib.c +++ b/gcc/config/m68k/fpgnulib.c @@ -166,6 +166,7 @@ __extendsfdf2 (float a1) register union float_long fl1; register union double_long dl; register long exp; + register long mant; fl1.f = a1; @@ -176,10 +177,23 @@ __extendsfdf2 (float a1) } dl.l.upper = SIGN (fl1.l); - exp = EXP (fl1.l) - EXCESS + EXCESSD; + exp = EXP(fl1.l); + mant = MANT (fl1.l) & ~HIDDEN; + if (exp == 0) + { + /* Denormal. */ + exp = 1; + while (!(mant & HIDDEN)) + { + mant <<= 1; + exp--; + } + mant &= ~HIDDEN; + } + exp = exp - EXCESS + EXCESSD; dl.l.upper |= exp << 20; - dl.l.upper |= (MANT (fl1.l) & ~HIDDEN) >> 3; - dl.l.lower = MANT (fl1.l) << 29; + dl.l.upper |= mant >> 3; + dl.l.lower = mant << 29; return dl.d; } @@ -203,6 +217,16 @@ __truncdfsf2 (double a1) /* shift double mantissa 6 bits so we can round */ mant = MANTD (dl1) >> 6; + /* Check for underflow and denormals. */ + if (exp <= 0) + { + if (exp < -24) + mant = 0; + else + mant >>= 1 - exp; + exp = 0; + } + /* now round and shift down */ mant += 1; mant >>= 1; |