Re: [Qemu-devel] [PATCH v3 3/4] softfloat: use floatx80_infinity in softfloat

2018-02-24 Thread Laurent Vivier
Le 24/02/2018 à 18:26, Richard Henderson a écrit :
> On 02/24/2018 09:21 AM, Laurent Vivier wrote:
>> I think the change should be in fact:
>>
>> @@ -4549,10 +4555,7 @@ int64_t floatx80_to_int64(floatx80 a,
>> float_status *status)
>>  if ( shiftCount <= 0 ) {
>>  if ( shiftCount ) {
>>  float_raise(float_flag_invalid, status);
>> -if (! aSign
>> - || (( aExp == 0x7FFF )
>> -  && ( aSig != LIT64( 0x8000 ) ) )
>> -   ) {
>> +if (!aSign || floatx80_is_any_nan(a)) {
>>  return LIT64( 0x7FFF );
>>  }
>>  return (int64_t) LIT64( 0x8000 );
>>
>> Do you agree?
> 
> Yep, looks good.

Thank you.

And according to your previous comment, floatx80_is_infinity() should
become:

static inline int floatx80_is_infinity(floatx80 a)
{
#if defined(TARGET_M68K)
return (a.high & 0x7fff) == floatx80_infinity.high && !(a.low << 1);
#else
return (a.high & 0x7fff) == floatx80_infinity.high &&
   a.low == floatx80_infinity.low;
#endif
}

Laurent



Re: [Qemu-devel] [PATCH v3 3/4] softfloat: use floatx80_infinity in softfloat

2018-02-24 Thread Richard Henderson
On 02/24/2018 09:21 AM, Laurent Vivier wrote:
> I think the change should be in fact:
> 
> @@ -4549,10 +4555,7 @@ int64_t floatx80_to_int64(floatx80 a,
> float_status *status)
>  if ( shiftCount <= 0 ) {
>  if ( shiftCount ) {
>  float_raise(float_flag_invalid, status);
> -if (! aSign
> - || (( aExp == 0x7FFF )
> -  && ( aSig != LIT64( 0x8000 ) ) )
> -   ) {
> +if (!aSign || floatx80_is_any_nan(a)) {
>  return LIT64( 0x7FFF );
>  }
>  return (int64_t) LIT64( 0x8000 );
> 
> Do you agree?

Yep, looks good.


r~



Re: [Qemu-devel] [PATCH v3 3/4] softfloat: use floatx80_infinity in softfloat

2018-02-24 Thread Laurent Vivier
Le 24/02/2018 à 03:26, Richard Henderson a écrit :
> On 02/23/2018 06:59 AM, Laurent Vivier wrote:
>> @@ -4550,8 +4556,8 @@ int64_t floatx80_to_int64(floatx80 a, float_status 
>> *status)
>>  if ( shiftCount ) {
>>  float_raise(float_flag_invalid, status);
>>  if (! aSign
>> - || (( aExp == 0x7FFF )
>> -  && ( aSig != LIT64( 0x8000 ) ) )
>> + || ((aExp == floatx80_infinity_high)
>> + && (aSig != floatx80_infinity_low))
>> ) {
> 
> As long as you're cleaning this up, m68k ignores the explicit integer bit when
> considering an infinity.  However, Intel doesn't ignore the bit -- it appears
> to treat 7fff.0* as a NaN.

According to the comment above the function:

"... If `a' is a NaN, the largest positive integer is returned.
Otherwise, if the conversion overflows, the largest integer with the
same sign as `a' is returned."

I think the change should be in fact:

@@ -4549,10 +4555,7 @@ int64_t floatx80_to_int64(floatx80 a,
float_status *status)
 if ( shiftCount <= 0 ) {
 if ( shiftCount ) {
 float_raise(float_flag_invalid, status);
-if (! aSign
- || (( aExp == 0x7FFF )
-  && ( aSig != LIT64( 0x8000 ) ) )
-   ) {
+if (!aSign || floatx80_is_any_nan(a)) {
 return LIT64( 0x7FFF );
 }
 return (int64_t) LIT64( 0x8000 );

Do you agree?

Thanks,
Laurent



Re: [Qemu-devel] [PATCH v3 3/4] softfloat: use floatx80_infinity in softfloat

2018-02-23 Thread Richard Henderson
On 02/23/2018 06:59 AM, Laurent Vivier wrote:
> @@ -4550,8 +4556,8 @@ int64_t floatx80_to_int64(floatx80 a, float_status 
> *status)
>  if ( shiftCount ) {
>  float_raise(float_flag_invalid, status);
>  if (! aSign
> - || (( aExp == 0x7FFF )
> -  && ( aSig != LIT64( 0x8000 ) ) )
> + || ((aExp == floatx80_infinity_high)
> + && (aSig != floatx80_infinity_low))
> ) {

As long as you're cleaning this up, m68k ignores the explicit integer bit when
considering an infinity.  However, Intel doesn't ignore the bit -- it appears
to treat 7fff.0* as a NaN.


r~