Skip to contentSkip to conversation

Alpha - IEEE 754 - denorm fix.

PATCH New George France 1 participant 1 message Mar 19, 2002 Alpha port

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Alpha - IEEE 754 - denorm fix.

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

arch/alpha/math-emu/math.c Mon Mar 18 18:26:53 2002 renamed from arch/alpha/math-emu/math.c Fri Sep 22 16:54:09 2000 +6 -6
@@ -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;
                        }