mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: George France <france@handhelds.org>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] Alpha - IEEE 754 - denorm fix.
Date: Tue, 19 Mar 2002 14:15:29 -0500	[thread overview]
Message-ID: <02031914152903.10791@shadowfax.middleearth> (raw)

[-- Attachment #1: Type: text/plain, Size: 1536 bytes --]

Start with a simple C program:

#include <stdio.h>
#include <values.h>

int main()
{
  float val = 1.40129846432481707e-45f;
  double dbl = val;

  printf("MINFLOAT is %e(flt)\n", MINFLOAT );
  printf("val is %e(flt) %g(dbl)\n", val, val);
}

Compile it:

	gcc -mieee -o ieee ieee.c

Results with the patch:

	MINFLOAT is 1.175494e-38(flt)
	val is 1.401298e-45(flt) 1.4013e-45(dbl)

Results without the patch:

	MINFLOAT is 1.175494e-38(flt)
	val is 2.652495e-315(flt) 2.65249e-315(dbl)

Patch follows inline & attached:

--- linux-2.4.18-orig/arch/alpha/math-emu/math.c        Fri Sep 22 16:54:09 
2000+++ linux-2.4.18/arch/alpha/math-emu/math.c     Mon Mar 18 18:26:53 2002
@@ -220,12 +220,12 @@
                                FP_CONV(S,D,1,1,SR,DB);
                                goto pack_s;
                        } else {
-                               /* CVTST need do nothing else but copy the
-                                  bits and repack.  */
-                               DR_c = DB_c;
-                               DR_s = DB_s;
-                               DR_e = DB_e;
-                               DR_f = DB_f;
+                               vb = alpha_read_fp_reg_s(fb);
+                               FP_UNPACK_SP(SB, &vb);
+                               DR_c = SB_c;
+                               DR_s = SB_s;
+                               DR_e = SB_e;
+                               DR_f = SB_f << ( 52 - 23 );
                                goto pack_d;
                        }


--George

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-alpha-ieee-denorm --]
[-- Type: text/x-c; name="patch-alpha-ieee-denorm", Size: 1006 bytes --]

--- linux-2.4.18-orig/arch/alpha/math-emu/math.c        Fri Sep 22 16:54:09 2000
+++ linux-2.4.18/arch/alpha/math-emu/math.c     Mon Mar 18 18:26:53 2002
@@ -220,12 +220,12 @@
                                FP_CONV(S,D,1,1,SR,DB);
                                goto pack_s;
                        } else {
-                               /* CVTST need do nothing else but copy the
-                                  bits and repack.  */
-                               DR_c = DB_c;
-                               DR_s = DB_s;
-                               DR_e = DB_e;
-                               DR_f = DB_f;
+                               vb = alpha_read_fp_reg_s(fb);
+                               FP_UNPACK_SP(SB, &vb);
+                               DR_c = SB_c;
+                               DR_s = SB_s;
+                               DR_e = SB_e;
+                               DR_f = SB_f << ( 52 - 23 );
                                goto pack_d;
                        }
 

                 reply	other threads:[~2002-03-19 19:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=02031914152903.10791@shadowfax.middleearth \
    --to=france@handhelds.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®