Correctly normalize values and handle zero inputs to scalbn functions.

Signed-off-by: Paul Brook <paul@codesourcery.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6102 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
pbrook 2008-12-19 12:59:28 +00:00
parent 731abc0d22
commit 69397542d6

View File

@ -5479,8 +5479,14 @@ float32 float32_scalbn( float32 a, int n STATUS_PARAM )
if ( aExp == 0xFF ) { if ( aExp == 0xFF ) {
return a; return a;
} }
aExp += n; if ( aExp != 0 )
return roundAndPackFloat32( aSign, aExp, aSig STATUS_VAR ); aSig |= 0x00800000;
else if ( aSig == 0 )
return a;
aExp += n - 1;
aSig <<= 7;
return normalizeRoundAndPackFloat32( aSign, aExp, aSig STATUS_VAR );
} }
float64 float64_scalbn( float64 a, int n STATUS_PARAM ) float64 float64_scalbn( float64 a, int n STATUS_PARAM )
@ -5496,8 +5502,14 @@ float64 float64_scalbn( float64 a, int n STATUS_PARAM )
if ( aExp == 0x7FF ) { if ( aExp == 0x7FF ) {
return a; return a;
} }
aExp += n; if ( aExp != 0 )
return roundAndPackFloat64( aSign, aExp, aSig STATUS_VAR ); aSig |= LIT64( 0x0010000000000000 );
else if ( aSig == 0 )
return a;
aExp += n - 1;
aSig <<= 10;
return normalizeRoundAndPackFloat64( aSign, aExp, aSig STATUS_VAR );
} }
#ifdef FLOATX80 #ifdef FLOATX80
@ -5514,9 +5526,12 @@ floatx80 floatx80_scalbn( floatx80 a, int n STATUS_PARAM )
if ( aExp == 0x7FF ) { if ( aExp == 0x7FF ) {
return a; return a;
} }
if (aExp == 0 && aSig == 0)
return a;
aExp += n; aExp += n;
return roundAndPackFloatx80( STATUS(floatx80_rounding_precision), return normalizeRoundAndPackFloatx80( STATUS(floatx80_rounding_precision),
aSign, aExp, aSig, 0 STATUS_VAR ); aSign, aExp, aSig, 0 STATUS_VAR );
} }
#endif #endif
@ -5534,8 +5549,14 @@ float128 float128_scalbn( float128 a, int n STATUS_PARAM )
if ( aExp == 0x7FFF ) { if ( aExp == 0x7FFF ) {
return a; return a;
} }
aExp += n; if ( aExp != 0 )
return roundAndPackFloat128( aSign, aExp, aSig0, aSig1, 0 STATUS_VAR ); aSig0 |= LIT64( 0x0001000000000000 );
else if ( aSig0 == 0 && aSig1 == 0 )
return a;
aExp += n - 1;
return normalizeRoundAndPackFloat128( aSign, aExp, aSig0, aSig1
STATUS_VAR );
} }
#endif #endif