diff mbox

[04/14] softfloat: Fix mixups of int and int16

Message ID 1326674823-13069-5-git-send-email-afaerber@suse.de
State New
Headers show

Commit Message

Andreas Färber Jan. 16, 2012, 12:46 a.m. UTC
normalizeFloat{32,64}Subnormal() expect the exponent as int16, not int.
This went unnoticed since int16 and uint16 were both typedef'ed to int.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 fpu/softfloat.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

Peter Maydell Jan. 16, 2012, 5:51 p.m. UTC | #1
On 16 January 2012 00:46, Andreas Färber <afaerber@suse.de> wrote:
> normalizeFloat{32,64}Subnormal() expect the exponent as int16, not int.
> This went unnoticed since int16 and uint16 were both typedef'ed to int.

I think at the time I wrote that I was being slightly conservative
because I didn't feel like confirming that we wouldn't overflow a
16 bit type.

Anyway, I have tested this patch:
 * in combination with your others
 * with typedefs set up so all int16 &co are the minimum width they
   could be
 * with typedefs so int16 &co are all 64 bits wide

and this all still gives the right results for ARM vfm, so

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM
diff mbox

Patch

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 81a7d1a..6dbcb1b 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -2131,7 +2131,7 @@  float32 float32_rem( float32 a, float32 b STATUS_PARAM )
 float32 float32_muladd(float32 a, float32 b, float32 c, int flags STATUS_PARAM)
 {
     flag aSign, bSign, cSign, zSign;
-    int aExp, bExp, cExp, pExp, zExp, expDiff;
+    int16 aExp, bExp, cExp, pExp, zExp, expDiff;
     uint32_t aSig, bSig, cSig;
     flag pInf, pZero, pSign;
     uint64_t pSig64, cSig64, zSig64;
@@ -3685,7 +3685,7 @@  float64 float64_rem( float64 a, float64 b STATUS_PARAM )
 float64 float64_muladd(float64 a, float64 b, float64 c, int flags STATUS_PARAM)
 {
     flag aSign, bSign, cSign, zSign;
-    int aExp, bExp, cExp, pExp, zExp, expDiff;
+    int16 aExp, bExp, cExp, pExp, zExp, expDiff;
     uint64_t aSig, bSig, cSig;
     flag pInf, pZero, pSign;
     uint64_t pSig0, pSig1, cSig0, cSig1, zSig0, zSig1;