NetBSD-Bugs archive

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

Re: toolchain/45310: some mixed int/float computations are wrong on mips64



The following reply was made to PR port-mips/45310; it has been noted by GNATS.

From: Manuel Bouyer <bouyer%antioche.eu.org@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: port-mips-maintainer%NetBSD.org@localhost, gnats-admin%NetBSD.org@localhost,
        netbsd-bugs%NetBSD.org@localhost
Subject: Re: toolchain/45310: some mixed int/float computations are wrong
 on mips64
Date: Wed, 31 Aug 2011 15:26:31 +0200

 On Tue, Aug 30, 2011 at 06:50:04PM +0000, David Holland wrote:
 >  Here's a second test that could allow to narrow down the issue:
 >  #include <stdio.h>
 >  #include <stdlib.h>
 >  #include <sys/types.h>
 >  
 >  main()
 >  {
 >          float a;
 >          int64_t b;
 >  
 >          a = 33.000000;
 >          b = a;
 >  
 >          printf("a %f b %d\n",a, (int)b);
 >  }
 >  
 >  cuba:/home/bouyer>./test3
 >  a 33.000000 b 0
 >  
 >  looks like the problem could be in __fixsfdi() (or one of the functions 
 > used by
 >  __fixsfdi()).
 
 I __fixsfdi() uses __fixunssfdi() which uses double to uint casts, which is
 the problem as shown by this new test:
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
 
 main()
 {
         double a;
        uint b;
 
        a = 33.000000;
        b = a;
 
        printf("a %f b %d\n",a, b);
 }
 
 cuba:/home/bouyer> gcc -o test4 test4.c
 cuba:/home/bouyer> ./test4
 a 33.000000 b 0
 
 tracking this down, I ended up in fixunsgen_ieee754.c:__fixunsgen32.
 It's called with
 exp=5, sign=0, mant_dig=53, fracbits=20, frac={0, 0, 32768}
 
 as exp - mant_dig is larger than 32, __fixunsgen32 returns 0.
 mant_dig is a constant from mips/float.h; I've no idea if it's right or
 wrong here ...
 
 -- 
 Manuel Bouyer <bouyer%antioche.eu.org@localhost>
      NetBSD: 26 ans d'experience feront toujours la difference
 --
 


Home | Main Index | Thread Index | Old Index