diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 61470bb5add..5382a0672c5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2005-12-29 Paul Brook + + * config/m68k/fpgnulib.c (__extendsfdf2): Handle negative zero. + (__truncdfsf2): Ditto. + (__extenddfxf2): Ditto. + (__truncxfdf2): Ditto. + * config/m68k/lb1sf68.asm (__addsf3): Return -0.0 for -0.0 + -0.0. + (__adddf3): Ditto. + 2005-12-29 Daniel Jacobowitz Paul Brook diff --git a/gcc/config/m68k/fpgnulib.c b/gcc/config/m68k/fpgnulib.c index a3ebc21608e..1ef43c758f0 100644 --- a/gcc/config/m68k/fpgnulib.c +++ b/gcc/config/m68k/fpgnulib.c @@ -241,13 +241,13 @@ __extendsfdf2 (float a1) fl1.f = a1; - if (!fl1.l) + dl.l.upper = SIGN (fl1.l); + if ((fl1.l & ~SIGNBIT) == 0) { - dl.l.upper = dl.l.lower = 0; + dl.l.lower = 0; return dl.d; } - dl.l.upper = SIGN (fl1.l); exp = EXP(fl1.l); mant = MANT (fl1.l) & ~HIDDEN; if (exp == 0) @@ -280,8 +280,11 @@ __truncdfsf2 (double a1) dl1.d = a1; - if (!dl1.l.upper && !dl1.l.lower) - return 0; + if ((dl1.l.upper & ~SIGNBIT) == 0 && !dl1.l.lower) + { + fl.l = SIGND(dl1); + return fl.f; + } exp = EXPD (dl1) - EXCESSD + EXCESS; @@ -398,10 +401,14 @@ __extenddfxf2 (double d) dl.d = d; /*printf ("dfxf in: %g\n", d);*/ - if (!dl.l.upper && !dl.l.lower) - return 0; - ldl.l.upper = SIGND (dl); + if ((dl.l.upper & ~SIGNBIT) == 0 && !dl.l.lower) + { + ldl.l.middle = 0; + ldl.l.lower = 0; + return ldl.ld; + } + exp = EXPD (dl) - EXCESSD + EXCESSX; ldl.l.upper |= exp << 16; ldl.l.middle = HIDDENX; @@ -427,14 +434,17 @@ __truncxfdf2 (long double ld) ldl.ld = ld; /*printf ("xfdf in: %s\n", dumpxf (ld));*/ - if (!ldl.l.upper && !ldl.l.middle && !ldl.l.lower) - return 0; + dl.l.upper = SIGNX (ldl); + if ((ldl.l.upper & ~SIGNBIT) == 0 && !ldl.l.middle && !ldl.l.lower) + { + dl.l.lower = 0; + return dl.d; + } exp = EXPX (ldl) - EXCESSX + EXCESSD; /* ??? quick and dirty: keep `exp' sane */ if (exp >= EXPDMASK) exp = EXPDMASK - 1; - dl.l.upper = SIGNX (ldl); dl.l.upper |= exp << (32 - (EXPDBITS + 1)); /* +1-1: add one for sign bit, but take one off for explicit-integer-bit */ dl.l.upper |= (ldl.l.middle & MANTXMASK) >> (EXPDBITS + 1 - 1); diff --git a/gcc/config/m68k/lb1sf68.asm b/gcc/config/m68k/lb1sf68.asm index e1b4c2fcc3d..2e239b33387 100644 --- a/gcc/config/m68k/lb1sf68.asm +++ b/gcc/config/m68k/lb1sf68.asm @@ -1285,7 +1285,12 @@ Ladddf$b: | Return b (if a is zero) movel d2,d0 movel d3,d1 - bra 1f + bne 1f | Check if b is -0 + cmpl IMM (0x80000000),d0 + bne 1f + andl IMM (0x80000000),d7 | Use the sign of a + clrl d0 + bra Ladddf$ret Ladddf$a: movel a6@(8),d0 movel a6@(12),d1 @@ -2570,16 +2575,13 @@ SYM (__addsf3): #endif movel a6@(8),d0 | get first operand movel a6@(12),d1 | get second operand - movel d0,d6 | get d0's sign bit ' + movel d0,a0 | get d0's sign bit ' addl d0,d0 | check and clear sign bit of a beq Laddsf$b | if zero return second operand - movel d1,d7 | save b's sign bit ' + movel d1,a1 | save b's sign bit ' addl d1,d1 | get rid of sign bit beq Laddsf$a | if zero return first operand - movel d6,a0 | save signs in address registers - movel d7,a1 | so we can use d6 and d7 - | Get the exponents and check for denormalized and/or infinity. movel IMM (0x00ffffff),d4 | mask to get fraction @@ -2950,7 +2952,12 @@ Laddsf$b$den: Laddsf$b: | Return b (if a is zero). movel a6@(12),d0 - bra 1f + cmpl IMM (0x80000000),d0 | Check if b is -0 + bne 1f + movel a0,d7 + andl IMM (0x80000000),d7 | Use the sign of a + clrl d0 + bra Laddsf$ret Laddsf$a: | Return a (if b is zero). movel a6@(8),d0