[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/22] softfloat: Fix factor 2 error for scalbn on d
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PATCH 06/22] softfloat: Fix factor 2 error for scalbn on denormal inputs |
Date: |
Tue, 31 Dec 2013 13:35:42 +0000 |
If the input to float*_scalbn() is denormal then it represents
a number 0.[mantissabits] * 2^(1-exponentbias) (and the actual
exponent field is all zeroes). This means that when we convert
it to our unpacked encoding the unpacked exponent must be one
greater than for a normal number, which represents
1.[mantissabits] * 2^(e-exponentbias) for an exponent field e.
This meant we were giving answers too small by a factor of 2 for
all denormal inputs.
Note that the float-to-int routines also have this behaviour
of not adjusting the exponent for denormals; however there it is
harmless because denormals will all convert to integer zero anyway.
Signed-off-by: Peter Maydell <address@hidden>
Reviewed-by: Aurelien Jarno <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
---
fpu/softfloat.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 41e4432..1af6ca5 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -6986,10 +6986,13 @@ float32 float32_scalbn( float32 a, int n STATUS_PARAM )
}
return a;
}
- if ( aExp != 0 )
+ if (aExp != 0) {
aSig |= 0x00800000;
- else if ( aSig == 0 )
+ } else if (aSig == 0) {
return a;
+ } else {
+ aExp++;
+ }
if (n > 0x200) {
n = 0x200;
@@ -7019,10 +7022,13 @@ float64 float64_scalbn( float64 a, int n STATUS_PARAM )
}
return a;
}
- if ( aExp != 0 )
+ if (aExp != 0) {
aSig |= LIT64( 0x0010000000000000 );
- else if ( aSig == 0 )
+ } else if (aSig == 0) {
return a;
+ } else {
+ aExp++;
+ }
if (n > 0x1000) {
n = 0x1000;
@@ -7052,8 +7058,12 @@ floatx80 floatx80_scalbn( floatx80 a, int n STATUS_PARAM
)
return a;
}
- if (aExp == 0 && aSig == 0)
- return a;
+ if (aExp == 0) {
+ if (aSig == 0) {
+ return a;
+ }
+ aExp++;
+ }
if (n > 0x10000) {
n = 0x10000;
@@ -7082,10 +7092,13 @@ float128 float128_scalbn( float128 a, int n
STATUS_PARAM )
}
return a;
}
- if ( aExp != 0 )
+ if (aExp != 0) {
aSig0 |= LIT64( 0x0001000000000000 );
- else if ( aSig0 == 0 && aSig1 == 0 )
+ } else if (aSig0 == 0 && aSig1 == 0) {
return a;
+ } else {
+ aExp++;
+ }
if (n > 0x10000) {
n = 0x10000;
--
1.8.5
- Re: [Qemu-devel] [PATCH 02/22] softfloat: Add float to 16bit integer conversions., (continued)
[Qemu-devel] [PATCH 22/22] target-arm: A64: Add support for FCVT between half, single and double, Peter Maydell, 2013/12/31
[Qemu-devel] [PATCH 16/22] target-arm: Rename A32 VFP conversion helpers, Peter Maydell, 2013/12/31
[Qemu-devel] [PATCH 10/22] softfloat: Fix float64_to_uint32_round_to_zero, Peter Maydell, 2013/12/31
[Qemu-devel] [PATCH 18/22] target-arm: A64: Add extra VFP fixed point conversion helpers, Peter Maydell, 2013/12/31
[Qemu-devel] [PATCH 06/22] softfloat: Fix factor 2 error for scalbn on denormal inputs,
Peter Maydell <=
[Qemu-devel] [PATCH 05/22] softfloat: Only raise Invalid when conversions to int are out of range, Peter Maydell, 2013/12/31
[Qemu-devel] [PATCH 09/22] softfloat: Fix float64_to_uint32, Peter Maydell, 2013/12/31
[Qemu-devel] [PATCH 17/22] target-arm: Ignore most exceptions from scalbn when doing fixpoint conversion, Peter Maydell, 2013/12/31
[Qemu-devel] [PATCH 21/22] target-arm: A64: Add 1-source 32-to-32 and 64-to-64 FP instructions, Peter Maydell, 2013/12/31
[Qemu-devel] [PATCH 04/22] softfloat: Fix float64_to_uint64, Peter Maydell, 2013/12/31
[Qemu-devel] [PATCH 13/22] softfloat: Add float16 <=> float64 conversion functions, Peter Maydell, 2013/12/31
[Qemu-devel] [PATCH 14/22] softfloat: Add support for ties-away rounding, Peter Maydell, 2013/12/31