From 7226fbce7b827c40d5f01fad00158585c019c18b Mon Sep 17 00:00:00 2001 From: pbrook Date: Wed, 28 Sep 2005 22:12:55 +0000 Subject: [PATCH] 2005-09-28 Paul Brook * config/m68k/fpgnulib.c (__extendsfdf2, __truncdfsf2): Handle denormals. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104745 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/config/m68k/fpgnulib.c | 30 +++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4c15aa2..6cce8e8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2005-09-28 Paul Brook + + * config/m68k/fpgnulib.c (__extendsfdf2, __truncdfsf2): Handle + denormals. + 2005-09-28 Richard Guenther PR tree-optimization/23853 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; -- 2.7.4