fpu/softfloat.c: Return correctly signed values from uint64_to_float32
PATCH 1/1 fpu/softfloat.c: Return correctly signed values from uint64_to_float32
The uint64_to_float32() conversion function was incorrectly always returning numbers with the sign bit set (ie negative numbers). Correct this so we return positive numbers instead.
---
As far as I can see we use this function only in the three PPC SPE insns efscfuf, efsctsf, efsctuf. It is therefore untested(!); if anybody with PPC hw to test against could check the results of those functions that would be cool.
fpu/softfloat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fpu/softfloat.c +2 -2
@@ -1238,7 +1238,7 @@ float32 uint64_to_float32( uint64 a STATUS_PARAM )if ( a ==0 )return float32_zero; shiftCount =countLeadingZeros64 ( a ) -40 ;if (0 <= shiftCount ) { -return packFloat32 (1 >0 ,0x95 - shiftCount, a<<shiftCount ); +return packFloat32 (0 ,0x95 - shiftCount, a<<shiftCount); }else { shiftCount +=7 ;
@@ -1248,7 +1248,7 @@ float32 uint64_to_float32( uint64 a STATUS_PARAM )else { a <<= shiftCount; } - return roundAndPackFloat32( 1 > 0, 0x9C - shiftCount, a STATUS_VAR ); + return roundAndPackFloat32(0, 0x9C - shiftCount, a STATUS_VAR); } }
Signature · 1 line
1.7.9.5
Quoted 10 lines · Peter Maydell
The
uint64_to_float32()conversion function was incorrectly always returning numbers with the sign bit set (ie negative numbers). Correct this so we return positive numbers instead.Signed-off-by Peter Maydell <[email protected]>---
As far as I can see we use this function only in the three PPC SPE insns efscfuf, efsctsf, efsctuf. It is therefore untested(!); if anybody with PPC hw to test against could check the results of those functions that would be cool.
...incidentally in two of those uses we're operating on a constant:
tmp = uint64_to_float64(1ULL << 32, &env->vec_status);
and it would probably be better to use make_float64() instead.
-- PMM
Quoted 11 lines · Peter Maydell
Quoted 10 lines · Peter Maydell
The
uint64_to_float32()conversion function was incorrectly always returning numbers with the sign bit set (ie negative numbers). Correct this so we return positive numbers instead.Signed-off-by Peter Maydell <[email protected]>---
As far as I can see we use this function only in the three PPC SPE insns efscfuf, efsctsf, efsctuf. It is therefore untested(!); if anybody with PPC hw to test against could check the results of those functions that would be cool.
SPE instructions are not common on the non-embedded world, as far as I know it should be tested using the e500 CPU. That said I don't have a kernel nor an image for such a machine.
Quoted 4 lines
...incidentally in two of those uses we're operating on a constant:
tmp =uint64_to_float64(1ULL << 32, &env->vec_status);
and it would probably be better to usemake_float64()instead.
Agreed.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Quoted 28 lines · Peter Maydell
The
uint64_to_float32()conversion function was incorrectly always returning numbers with the sign bit set (ie negative numbers). Correct this so we return positive numbers instead.Signed-off-by Peter Maydell <[email protected]>---
As far as I can see we use this function only in the three PPC SPE insns efscfuf, efsctsf, efsctuf. It is therefore untested(!); if anybody with PPC hw to test against could check the results of those functions that would be cool.fpu/softfloat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fpu/softfloat.c +1
-1@@ -1238,7 +1238,7 @@ float32 uint64_to_float32( uint64 a STATUS_PARAM )if ( a ==0 )return float32_zero; shiftCount =countLeadingZeros64 ( a ) -40 ;if (0 <= shiftCount ) { -return packFloat32 (1 >0 ,0x95 - shiftCount, a<<shiftCount ); +return packFloat32 (0 ,0x95 - shiftCount, a<<shiftCount); }else { shiftCount +=7 ;
fpu/softfloat.c float32 uint64_to_float32( uint64 a STATUS_PARAM ) · line 1254
Quoted 8 lines
fpu/softfloat.c +1
-1@@ -1248,7 +1248,7 @@ float32 uint64_to_float32( uint64 a STATUS_PARAM )else { a <<= shiftCount; } - return roundAndPackFloat32( 1 > 0, 0x9C - shiftCount, a STATUS_VAR ); + return roundAndPackFloat32(0, 0x9C - shiftCount, a STATUS_VAR); } }
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Aurelien Jarno
AppliedQuoted 28 lines · Peter Maydell
The
uint64_to_float32()conversion function was incorrectly always returning numbers with the sign bit set (ie negative numbers). Correct this so we return positive numbers instead.Signed-off-by Peter Maydell <[email protected]>---
As far as I can see we use this function only in the three PPC SPE insns efscfuf, efsctsf, efsctuf. It is therefore untested(!); if anybody with PPC hw to test against could check the results of those functions that would be cool.fpu/softfloat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fpu/softfloat.c +1
-1@@ -1238,7 +1238,7 @@ float32 uint64_to_float32( uint64 a STATUS_PARAM )if ( a ==0 )return float32_zero; shiftCount =countLeadingZeros64 ( a ) -40 ;if (0 <= shiftCount ) { -return packFloat32 (1 >0 ,0x95 - shiftCount, a<<shiftCount ); +return packFloat32 (0 ,0x95 - shiftCount, a<<shiftCount); }else { shiftCount +=7 ;
fpu/softfloat.c float32 uint64_to_float32( uint64 a STATUS_PARAM ) · line 1254
Quoted 8 lines
fpu/softfloat.c +1
-1@@ -1248,7 +1248,7 @@ float32 uint64_to_float32( uint64 a STATUS_PARAM )else { a <<= shiftCount; } - return roundAndPackFloat32( 1 > 0, 0x9C - shiftCount, a STATUS_VAR ); + return roundAndPackFloat32(0, 0x9C - shiftCount, a STATUS_VAR); } }
Thanks, applied.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net