pkgsrc-Bugs archive

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

Re: pkg/34571: TME sun3 emulator doesn't consider floating point infinities t...



The following reply was made to PR pkg/34571; it has been noted by GNATS.

From: SigmFSK%aol.com@localhost
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: pkg/34571: TME sun3 emulator doesn't consider floating point 
infinities t...
Date: Thu, 28 Sep 2006 19:04:42 EDT

 TME just maps the "fcmp" instruction to "fsub", which is why it doesn't  
 consider infinity equal to itself (since infinity minus infinity should not  
equal 
 0.0, but infinity should equal infinity).  
 
 The following changes correct this behavior, and allow the following  
 gcc-3.3.3-testsuite tests to pass under NetBSD 3.0 in TME (as they pass on a  
real 
 sun3):
 960405-1.c
 hugeval.c
 inf-1.c
 mzero2.c
 mzero3.c
 
 To fix, I did the following:
 
 modified the script that maps the  m6888x instructions to ieee754 routines so 
 that FCMP has its own routines,  distinct from FSUB, then did a make in the 
 m68k directory.
 
 # diff  m6888x-auto.sh.orig  m6888x-auto.sh
 139c139
 <            56) name=cmp ; name_ieee754=sub ; optype=DST_SRC ;; # fcmp pp  
 326
 ---
 >            56) name=cmp ; optype=DST_SRC ;;    # fcmp pp 326
 #  
 
 
 modified the script that generates the ieee754 routines to add the  cmp, then 
 did a make in the ieee754 directory (notice the last line of  difference is 
 the change to fix the fneg problem of fneg of 0.0 not being  -0.0):
 
 # diff ieee754-ops-auto.sh.orig  ieee754-ops-auto.sh
 129c129
 <            for name in add sub mul div  \
 ---
 >           for  name in add cmp sub mul div  \
 147c147
 <                add | sub | mul | div | rem | pow |  scale)
 ---
 >                add | cmp | sub | mul | div | rem | pow |  scale)
 245a246
 >                    *-cmp) op_builtin='-'  ;;
 252c253
 <                    partial-neg | unknown-neg) op0=0 ; op_builtin='-'; 
 op1=src0  ;;
 ---
 >                    partial-neg | unknown-neg) op0=-1.0 ; op_builtin='*'; 
 op1=src0  ;;
 #
 
 after generating the new ieee754-ops-auto.c, modified each of the  cmp 
 routines (which were created identically to the sub routines) to indicate  
that 
 positive infinity is equal to itself, as is negative infinity equal to  itself:
 
 51,57d50
 <   if (tme_float_is_inf(src0,  TME_FLOAT_FORMAT_IEEE754_SINGLE )  &
 <       tme_float_is_inf(src1,  TME_FLOAT_FORMAT_IEEE754_SINGLE)  &
 <       (tme_float_is_negative(src0,  TME_FLOAT_FORMAT_IEEE754_SINGLE) ==
 <        tme_float_is_negative(src1,  TME_FLOAT_FORMAT_IEEE754_SINGLE)))
 <    tme_ieee754_single_value_builtin_set(dst,  
 TME_FLOAT_FORMAT_IEEE754_SINGLE_BUILTIN, 0.0);
 < else
 <  
 591,597d583
 <   if (tme_float_is_inf(src0,  TME_FLOAT_FORMAT_IEEE754_DOUBLE )  &
 <       tme_float_is_inf(src1,  TME_FLOAT_FORMAT_IEEE754_DOUBLE)  &
 <       (tme_float_is_negative(src0,  TME_FLOAT_FORMAT_IEEE754_DOUBLE) ==
 <        tme_float_is_negative(src1,  TME_FLOAT_FORMAT_IEEE754_DOUBLE)))
 <    tme_ieee754_double_value_builtin_set(dst,  
 TME_FLOAT_FORMAT_IEEE754_DOUBLE_BUILTIN, 0.0);
 < else
 <  
 1135,1141d1120
 <   if (tme_float_is_inf(src0,  TME_FLOAT_FORMAT_IEEE754_EXTENDED80 )  &
 <       tme_float_is_inf(src1,  TME_FLOAT_FORMAT_IEEE754_EXTENDED80)  &
 <       (tme_float_is_negative(src0,  TME_FLOAT_FORMAT_IEEE754_EXTENDED80)  ==
 <       tme_float_is_negative(src1,  TME_FLOAT_FORMAT_IEEE754_EXTENDED80)))
 <    tme_ieee754_extended80_value_builtin_set(dst,  
 TME_FLOAT_FORMAT_IEEE754_EXTENDED80_BUILTIN, 0.0);
 < else
 <  
 1723,1729d1701
 <   if (tme_float_is_inf(src0,  TME_FLOAT_FORMAT_IEEE754_QUAD )  &
 <       tme_float_is_inf(src1,  TME_FLOAT_FORMAT_IEEE754_QUAD) &
 <        (tme_float_is_negative(src0, TME_FLOAT_FORMAT_IEEE754_QUAD)  ==
 <       tme_float_is_negative(src1,  TME_FLOAT_FORMAT_IEEE754_QUAD)))
 <    tme_ieee754_quad_value_builtin_set(dst, 
 TME_FLOAT_FORMAT_IEEE754_QUAD_BUILTIN,  0.0);
 < else
 < 
 2842,2848d2813
 <   if  (tme_float_is_inf(src0, TME_FLOAT_FORMAT_IEEE754_SINGLE )  &
 <       tme_float_is_inf(src1,  TME_FLOAT_FORMAT_IEEE754_SINGLE)  &
 <       (tme_float_is_negative(src0,  TME_FLOAT_FORMAT_IEEE754_SINGLE) ==
 <        tme_float_is_negative(src1,  TME_FLOAT_FORMAT_IEEE754_SINGLE)))
 <    tme_ieee754_single_value_builtin_set(dst,  
 TME_FLOAT_FORMAT_IEEE754_SINGLE_BUILTIN, 0.0);
 < 
 <  else
 3367,3373d3331
 <   if (tme_float_is_inf(src0,  TME_FLOAT_FORMAT_IEEE754_DOUBLE )  &
 <       tme_float_is_inf(src1,  TME_FLOAT_FORMAT_IEEE754_DOUBLE)  &
 <       (tme_float_is_negative(src0,  TME_FLOAT_FORMAT_IEEE754_DOUBLE) ==
 <        tme_float_is_negative(src1,  TME_FLOAT_FORMAT_IEEE754_DOUBLE)))
 <    tme_ieee754_double_value_builtin_set(dst,  
 TME_FLOAT_FORMAT_IEEE754_DOUBLE_BUILTIN, 0.0);
 < else
 <  
 3892,3898d3849
 <   if (tme_float_is_inf(src0,  TME_FLOAT_FORMAT_IEEE754_EXTENDED80 )  &
 <       tme_float_is_inf(src1,  TME_FLOAT_FORMAT_IEEE754_EXTENDED80)  &
 <       (tme_float_is_negative(src0,  TME_FLOAT_FORMAT_IEEE754_EXTENDED80)  ==
 <       tme_float_is_negative(src1,  TME_FLOAT_FORMAT_IEEE754_EXTENDED80)))
 <    tme_ieee754_extended80_value_builtin_set(dst,  
 TME_FLOAT_FORMAT_IEEE754_EXTENDED80_BUILTIN, 0.0);
 < else
 <  
 4417,4423d4367
 <   if (tme_float_is_inf(src0,  TME_FLOAT_FORMAT_IEEE754_QUAD )  &
 <       tme_float_is_inf(src1,  TME_FLOAT_FORMAT_IEEE754_QUAD) &
 <        (tme_float_is_negative(src0, TME_FLOAT_FORMAT_IEEE754_QUAD)  ==
 <       tme_float_is_negative(src1,  TME_FLOAT_FORMAT_IEEE754_QUAD)))
 <    tme_ieee754_quad_value_builtin_set(dst, 
 TME_FLOAT_FORMAT_IEEE754_QUAD_BUILTIN,  0.0);
 < else
 < 
 5662,5668d5605
 <   if  (tme_float_is_inf(src0, TME_FLOAT_FORMAT_IEEE754_SINGLE )  &
 <       tme_float_is_inf(src1,  TME_FLOAT_FORMAT_IEEE754_SINGLE)  &
 <       (tme_float_is_negative(src0,  TME_FLOAT_FORMAT_IEEE754_SINGLE) ==
 <        tme_float_is_negative(src1,  TME_FLOAT_FORMAT_IEEE754_SINGLE)))
 <    tme_ieee754_single_value_builtin_set(dst,  
 TME_FLOAT_FORMAT_IEEE754_SINGLE_BUILTIN, 0.0);
 < else
 <  
 5963,5969d5899
 <   if (tme_float_is_inf(src0,  TME_FLOAT_FORMAT_IEEE754_DOUBLE )  &
 <       tme_float_is_inf(src1,  TME_FLOAT_FORMAT_IEEE754_DOUBLE)  &
 <       (tme_float_is_negative(src0,  TME_FLOAT_FORMAT_IEEE754_DOUBLE) ==
 <        tme_float_is_negative(src1,  TME_FLOAT_FORMAT_IEEE754_DOUBLE)))
 <    tme_ieee754_double_value_builtin_set(dst,  
 TME_FLOAT_FORMAT_IEEE754_DOUBLE_BUILTIN, 0.0);
 < else
 <  
 6264,6270d6193
 <   if (tme_float_is_inf(src0,  TME_FLOAT_FORMAT_IEEE754_EXTENDED80 )  &
 <       tme_float_is_inf(src1,  TME_FLOAT_FORMAT_IEEE754_EXTENDED80)  &
 <       (tme_float_is_negative(src0,  TME_FLOAT_FORMAT_IEEE754_EXTENDED80)  ==
 <       tme_float_is_negative(src1,  TME_FLOAT_FORMAT_IEEE754_EXTENDED80)))
 <    tme_ieee754_extended80_value_builtin_set(dst,  
 TME_FLOAT_FORMAT_IEEE754_EXTENDED80_BUILTIN, 0.0);
 < else
 <  
 6565,6571d6487
 <   if (tme_float_is_inf(src0,  TME_FLOAT_FORMAT_IEEE754_QUAD )  &
 <       tme_float_is_inf(src1,  TME_FLOAT_FORMAT_IEEE754_QUAD) &
 <        (tme_float_is_negative(src0, TME_FLOAT_FORMAT_IEEE754_QUAD)  ==
 <       tme_float_is_negative(src1,  TME_FLOAT_FORMAT_IEEE754_QUAD)))
 <    tme_ieee754_quad_value_builtin_set(dst, 
 TME_FLOAT_FORMAT_IEEE754_QUAD_BUILTIN,  0.0);
 < else
 < 
 
 The process of hand-editing the auto  generated c file should be automated, 
 but I believe the above logic is  sound.
 /arthur
  
 



Home | Main Index | Thread Index | Old Index