public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [BUG] PPC math-emu multiply problem
@ 2004-07-29 13:14 Greg Weeks
  2004-07-29 14:06 ` Kumar Gala
  0 siblings, 1 reply; 15+ messages in thread
From: Greg Weeks @ 2004-07-29 13:14 UTC (permalink / raw)
  To: linux-kernel

I'm seeing what appears to be a bug in the ppc kernel trap math 
emulator. An extreme case for multiplies isn't working the way gcc 
soft-float or hardware floating point is. The value in mindble is the 
smallest that can be represented in a double. When we try to divide it 
by two we should see an underflow and a return value of 0. We see this 
when using soft-float in gcc, or when there is HW floating point 
support, but it fails when the kernel trap emulator is used.

If anyone can verify this on a PPC other than an 8560 without hardware 
floating point I'd appreciate it. I did all of these tests with a 2.6.X 
based kernels. The x86 was 2.6.6 vanilla, 8560 is 2.6.6 with lots of 
stuff added and support for 8560. The 8260 was 2.6.0 with changes. I 
bumped into this with the LSB ldexp test. A simple multiply shows the 
problem though.

Greg Weeks

mulbug.c file
------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
#include <errno.h>

int main()
{
        double  x, rtval;
        double mindble = 4.9406564584124654418e-324;

        x = mindble;

        printf("x = %.20g\n", x);

        errno = 0;
        rtval = ldexp(x, -1);

        printf("using ldexp(x, -1) ERRNO = %d - %s,  %.20g\n",
            errno, strerror(errno), rtval);

        printf("using (x * .5) %.20g\n", (x * .5));

   exit(0);
}
-----------------------------------------

compile with:
gcc mulbug.c -lm -o mulbug


on an 8260 ppc with HW float.

x = 4.9406564584124654418e-324
using ldexp(x, -1) ERRNO = 34 - Numerical result out of range,  0
using (x * .5) 0

on an x86 with HW float.

x = 4.9406564584124654418e-324
using ldexp(x, -1) ERRNO = 34 - Numerical result out of range,  0
using (x * .5) 0

on an 8560 ppc with kernel trap float emulator.

x = 4.9406564584124654418e-324
using ldexp(x, -1) ERRNO = 0 - Success,  4.9406564584124654418e-324
using (x * .5) 4.9406564584124654418e-324

on an 8260 with soft-float in the gcc

x = 4.9406564584124654418e-324
using ldexp(x, -1) ERRNO = 34 - Numerical result out of range,  0
using (x * .5) 0



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2004-08-16 18:35 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-29 13:14 [BUG] PPC math-emu multiply problem Greg Weeks
2004-07-29 14:06 ` Kumar Gala
2004-07-29 14:26   ` Greg Weeks
2004-07-29 19:22   ` Dan Malek
2004-07-29 19:47     ` La Monte H.P. Yarroll
2004-07-30 14:45     ` Greg Weeks
2004-07-30 15:23       ` Greg Weeks
2004-08-09 16:56         ` Tom Rini
2004-08-09 17:42           ` Dan Malek
2004-08-09 22:18             ` La Monte H.P. Yarroll
2004-08-09 22:23             ` Tom Rini
2004-08-16 13:02               ` Greg Weeks
2004-08-16 14:48                 ` Tom Rini
2004-08-16 18:28                   ` Greg Weeks
2004-08-16 18:35                     ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox