[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r11038 - in /libdfp/trunk: ./ sysdeps/powerpc/dfpu/ tests/



Author: ryanarn
Date: Fri Jul 23 10:20:29 2010
New Revision: 11038

Log:
Cleaned up test-suite expectations and in the process found and fixed a bug
with fpclassifyd32().

2010-07-23  Ryan S. Arnold  <rsa@xxxxxxxxxx>

	* Makefile.in: Removed commented out code.
	* tests/test-logd.c: Corrected expected values for a _Decimal64 NAN
	declet series.
	* tests/test-fpclassify.c: Added cases for + and -
	__DEC[32|64|128]_SUBNORMAL_MIN__.
	* tests/scaffold.c: Modified spacing in macro output for 'Success'.
	* tests/test-isfinite.c: Corrected expected values for negative
	numbers to return -1.  Corrected expected value for DEC_NAN to '0'.
	* tests/test-strtod.c: Cleaned up.  Still failing.
	* sysdeps/powerpc/dfpu/fpclassifyd32.c (fpclassifyd32): Since
	_Decimal32 is promoted to _Decimal64 and __DEC32_SUBNORMAL_MIN__ falls
	within the bounds of _Decimal64 a special case to range check for
	_Decimal32 as required.
	* sysdeps/powerpc/dfpu/powd64.c: Whitespace correction.
	* strtod32.c: Started to cleanup the code.


Modified:
    libdfp/trunk/ChangeLog
    libdfp/trunk/Makefile.in
    libdfp/trunk/strtod32.c
    libdfp/trunk/sysdeps/powerpc/dfpu/fpclassifyd32.c
    libdfp/trunk/sysdeps/powerpc/dfpu/powd64.c
    libdfp/trunk/tests/scaffold.c
    libdfp/trunk/tests/test-fpclassify.c
    libdfp/trunk/tests/test-isfinite.c
    libdfp/trunk/tests/test-logd.c
    libdfp/trunk/tests/test-strtod.c

Modified: libdfp/trunk/ChangeLog
==============================================================================
--- libdfp/trunk/ChangeLog (original)
+++ libdfp/trunk/ChangeLog Fri Jul 23 10:20:29 2010
@@ -1,3 +1,22 @@
+2010-07-23  Ryan S. Arnold  <rsa@xxxxxxxxxx>
+
+	* Makefile.in: Removed commented out code.
+	* tests/test-logd.c: Corrected expected values for a _Decimal64 NAN
+	declet series.
+	* tests/test-fpclassify.c: Added cases for + and -
+	__DEC[32|64|128]_SUBNORMAL_MIN__.
+	* tests/scaffold.c: Modified spacing in macro output for 'Success'.
+	* tests/test-isfinite.c: Corrected expected values for negative
+	numbers to return -1.  Corrected expected value for DEC_NAN to '0'.
+	* tests/test-strtod.c: Cleaned up.  Still failing.
+	* sysdeps/powerpc/dfpu/fpclassifyd32.c (fpclassifyd32): Since
+	_Decimal32 is promoted to _Decimal64 and __DEC32_SUBNORMAL_MIN__ falls
+	within the bounds of _Decimal64 a special case to range check for
+	_Decimal32 as required.
+	* sysdeps/powerpc/dfpu/powd64.c: Whitespace correction.
+	* strtod32.c: Started to cleanup the code.
+
+
 2010-07-21  Ryan S. Arnold <rsa@xxxxxxxxxx>
 
 	* Makefile.in: Added test-numdigits, test-get_digits, and test-left_justify.
@@ -34,7 +53,7 @@
 	printing errors.  It should now fully support %f, %e, %g, and %a in
 	the myriad of bizarre combinations.
 
-2010-07-06  Ryan S. Arnold <rsa@xxxxxxxxxx>
+2010-07-06  Ryan S. Arnold  <rsa@xxxxxxxxxx>
 
 	* Makefile.in: Added test-strtod testcase.
 	* tests/test-logd.c: Cleaned up some comments.

Modified: libdfp/trunk/Makefile.in
==============================================================================
--- libdfp/trunk/Makefile.in (original)
+++ libdfp/trunk/Makefile.in Fri Jul 23 10:20:29 2010
@@ -9,11 +9,6 @@
 exec_prefix = @exec_prefix@
 libdir = @libdir@
 includedir = @includedir@
-
-#cc_msize = @cc_msize@
-
-# Not used on non-Z systems, i.e. empty
-#cc_mzarch = @cc_mzarch@
 
 # Where to install the library and object files.
 ifndef libdir
@@ -72,9 +67,6 @@
 cflags-cpu = $(submachine_opt)
 asflags-cpu = $(submachine_opt)
 endif
-
-#default_cflags := @CFLAGS@ -m$(cc_msize) $(cc_mzarch)
-#default_asflags := @ASFLAGS@ -m$(cc_msize) $(cc_mzarch)
 
 default_cflags := @CFLAGS@
 default_asflags := @ASFLAGS@
@@ -251,7 +243,6 @@
 $(top_builddir)/$(SHARED_REALNAME_LIB): $(top_builddir)/$(dfp_name).map $(dfp_backend)/$(dfp_backend_lib) $(addsuffix .os,$(libdfp_files))
 	@echo +Linking shared object files into $@.
 	$(CC) $(CFLAGS) -shared -Wl,-soname,$(SHARED_SONAME_LIB) -Bsymbolic -Wl,--whole-archive $(dfp_backend)/$(dfp_backend_lib) -Wl,--no-whole-archive -Wl,--version-script,$(dfp_name).map $(addsuffix .os,$(libdfp_files)) -o $@ -lm
-	#$(CC) $(CFLAGS) -shared -Wl,-soname,$(SHARED_SONAME_LIB) -Bsymbolic -Wl,--whole-archive $(dfp_backend)/$(dfp_backend_lib) -Wl,--no-whole-archive -Wl,--version-script,$(dfp_name).map $(wordlist 3,$(words $?),$?) -o $@ -lm
 	@echo
 
 # The LIBDFP version script support is strongly based upon the GLIBC version

Modified: libdfp/trunk/strtod32.c
==============================================================================
--- libdfp/trunk/strtod32.c (original)
+++ libdfp/trunk/strtod32.c Fri Jul 23 10:20:29 2010
@@ -420,7 +420,7 @@
   cp = nptr - 1;
   /* Ignore leading white space.  */
   do
-    c = *++cp;
+    c = *++cp; /* c is last character read, cp is last character processed.  */
   while (ISSPACE (c));
 
   /* Get sign of the result.  */

Modified: libdfp/trunk/sysdeps/powerpc/dfpu/fpclassifyd32.c
==============================================================================
--- libdfp/trunk/sysdeps/powerpc/dfpu/fpclassifyd32.c (original)
+++ libdfp/trunk/sysdeps/powerpc/dfpu/fpclassifyd32.c Fri Jul 23 10:20:29 2010
@@ -38,17 +38,29 @@
 INTERNAL_FUNCTION_NAME (DEC_TYPE x)
 {
   int result = 0;
-/* check in order, FP_NORMAL, FP_ZERO, FP_SUBNORMAL, FP_INFINITE,
-   FP_NAN.  The though is the most liky case exits early.  */
+#if _DECIMAL_SIZE == 32
+  /* Since _Decimal32 is promoted to _Decimal64, __DEC32_SUBNORMAL_MIN__ is well
+   * within the bounds of a _Decimal64.  This means that we need to do our range
+   * check for __DEC32_SUBNORMAL_MIN__ before dropping into the asm code.  This
+   * is crude.  The asm code should probably be broken into two parts with this
+   * code in between so the zero, <-1 and > 1 checks aren't redundant.  */
+  if (x != 0 && x > -1 && x < 1 && x <= __DEC32_SUBNORMAL_MIN__)
+    return FP_SUBNORMAL;
+#endif
+
+/* Check in order, FP_NORMAL, FP_ZERO, FP_SUBNORMAL, FP_INFINITE,
+   FP_NAN.  The most likely case exits early.  */
   __asm__(	"dtstdc cr0,%1,0x08;"
 		"li %0,4;"
 		"beq cr0,1f;"
 		"dtstdc cr0,%1,0x20;"
 		"li %0,2;"
 		"beq cr0,1f;"
+#if _DECIMAL_SIZE != 32 /* This was alread done for _Decimal32 earlier.  */
 		"dtstdc cr0,%1,0x10;"
 		"li %0,3;"
 		"beq cr0,1f;"
+#endif
 		"dtstdc cr0,%1,0x04;"
 		"li %0,1;"
 		"beq cr0,1f;"

Modified: libdfp/trunk/sysdeps/powerpc/dfpu/powd64.c
==============================================================================
--- libdfp/trunk/sysdeps/powerpc/dfpu/powd64.c (original)
+++ libdfp/trunk/sysdeps/powerpc/dfpu/powd64.c Fri Jul 23 10:20:29 2010
@@ -33,47 +33,6 @@
 #define FUNCTION_NAME pow
 
 #include <dfpmacro.h>
-
-static _Decimal64
-oldmypowNd64 (_Decimal64 val, int N)
-{
-  _Decimal128 powStack[32];
-  _Decimal128 p = val;
-  _Decimal64 result;
-  long i, j, n;
-  n = N;
-
-/*
-  To minimize the number of multiply operations, first compute the
-  power series where the exponent is a power of 2.
-*/
-  i = 0;
-  powStack[0] = 1.DD;
-  while (n > 0)
-    {
-      if (n & 1)
-	powStack[++i] = p;
-
-      n = n >> 1;
-      if (n > 0)
-	p *= p;
-    }
-/*
-  Then compute the power result from the saved partial powers.
-*/
-  if ( i > 1 )
-    {
-      p = powStack[1];
-      for (j=2; j<=i; j++)
-	p *= powStack[j];
-      result = p;
-    }
-  else
-    result = powStack[i];
-
-  return result;
-}
-
 
 static DEC_TYPE 
 intpow (DEC_TYPE val, int N)
@@ -81,7 +40,7 @@
   DEC_TYPE result = 1;
   DEC_TYPE p = val;
   int mask = 1;
-  
+
   while (mask <= N)
     {
       if (mask & N) result *= p;

Modified: libdfp/trunk/tests/scaffold.c
==============================================================================
--- libdfp/trunk/tests/scaffold.c (original)
+++ libdfp/trunk/tests/scaffold.c Fri Jul 23 10:20:29 2010
@@ -99,7 +99,7 @@
     fprintf(stderr, "%-3d Error:   Expected: \"%s\"\n             Result:   \"%s\"\n    in: %s:%d.\n\n", testnum,bufx,bufy,f,l); \
     ++fail; \
   } else { \
-    fprintf(stdout, "%-3d Success: Expected: \"%s\"\n             Result:   \"%s\"\n    in: %s:%d.\n\n", testnum,bufx,bufy,f,l); \
+    fprintf(stdout, "%-3d Success: Expected: \"%s\"\n               Result:   \"%s\"\n    in: %s:%d.\n\n", testnum,bufx,bufy,f,l); \
   } \
 } while (0)
 

Modified: libdfp/trunk/tests/test-fpclassify.c
==============================================================================
--- libdfp/trunk/tests/test-fpclassify.c (original)
+++ libdfp/trunk/tests/test-fpclassify.c Fri Jul 23 10:20:29 2010
@@ -50,8 +50,10 @@
   {__LINE__, 0.0DL, FP_ZERO, "%d"},
   {__LINE__, 2.3DL, FP_NORMAL, "%d"},
   {__LINE__, -2.3DL, FP_NORMAL, "%d"},
+  {__LINE__, -__DEC128_SUBNORMAL_MIN__, FP_SUBNORMAL, "%d"}, /* Subnormal  */
   {__LINE__, __DEC128_SUBNORMAL_MIN__, FP_SUBNORMAL, "%d"}, /* Subnormal  */
   {__LINE__, 0.000000000000000000000000000000001E-6143DL, FP_SUBNORMAL, "%d"},
+  {__LINE__, -0.000000000000000000000000000000001E-6143DL, FP_SUBNORMAL, "%d"},
   {__LINE__, __DEC128_MIN__, FP_NORMAL, "%d"},
   {0,0,0,0 }
 };
@@ -72,7 +74,9 @@
   {__LINE__, 2.3DD, FP_NORMAL, "%d"},
   {__LINE__, -2.3DD, FP_NORMAL, "%d"},
   {__LINE__, __DEC64_SUBNORMAL_MIN__, FP_SUBNORMAL, "%d"}, /* Subnormal  */
+  {__LINE__, -__DEC64_SUBNORMAL_MIN__, FP_SUBNORMAL, "%d"}, /* Subnormal  */
   {__LINE__, 0.000000000000001E-383DD, FP_SUBNORMAL, "%d"},
+  {__LINE__, -0.000000000000001E-383DD, FP_SUBNORMAL, "%d"},
   {__LINE__, __DEC64_MIN__, FP_NORMAL, "%d"},
   {0,0,0,0 }
 };
@@ -92,8 +96,14 @@
   {__LINE__, 0.0DF, FP_ZERO, "%d"},
   {__LINE__, 2.3DF, FP_NORMAL, "%d"},
   {__LINE__, -2.3DF, FP_NORMAL, "%d"},
+/* Known failure on hard-dfp due to promotion to _Decimal64.  These are well
+ * within the range of NORMAL for _Decimal64.  */
+//#ifndef _ARCH_PWR6 
   {__LINE__, __DEC32_SUBNORMAL_MIN__, FP_SUBNORMAL, "%d"}, /* Subnormal  */
+  {__LINE__, -__DEC32_SUBNORMAL_MIN__, FP_SUBNORMAL, "%d"}, /* Subnormal  */
   {__LINE__, 0.000001E-95DF, FP_SUBNORMAL, "%d"},
+  {__LINE__, -0.000001E-95DF, FP_SUBNORMAL, "%d"},
+//#endif
   {__LINE__, __DEC32_MIN__, FP_NORMAL, "%d"},
   {0,0,0,0 }
 };

Modified: libdfp/trunk/tests/test-isfinite.c
==============================================================================
--- libdfp/trunk/tests/test-isfinite.c (original)
+++ libdfp/trunk/tests/test-isfinite.c Fri Jul 23 10:20:29 2010
@@ -45,10 +45,12 @@
 d128_type printf_d128s[] =
 {
   {__LINE__, 1.20DL, 1,  "%d"},
-  {__LINE__, DEC_NAN, 1,  "%d"},
+  {__LINE__, DEC_NAN, 0,  "%d"},
   {__LINE__, HUGE_VAL_D128, 0, "%d"},
   {__LINE__, DEC_INFINITY, 0, "%d"},
-  {__LINE__, -1.95DL, 1, "%d"},
+  /* isfinite returns 'nonzero' if the argument is finite.  This could be
+   * anything other than zero.  */
+  {__LINE__, -1.95DL, -1, "%d"},
   {0,0,0,0 }
 };
 
@@ -62,10 +64,10 @@
 d64_type printf_d64s[] =
 {
   {__LINE__, 1.20DD, 1,  "%d"},
-  {__LINE__, DEC_NAN, 1,  "%d"},
+  {__LINE__, DEC_NAN, 0,  "%d"},
   {__LINE__, HUGE_VAL_D64, 0, "%d"},
   {__LINE__, DEC_INFINITY, 0, "%d"},
-  {__LINE__, -1.95DD, 1, "%d"},
+  {__LINE__, -1.95DD, -1, "%d"},
   {0,0,0,0 }
 };
 
@@ -79,10 +81,10 @@
 d32_type printf_d32s[] =
 {
   {__LINE__, 1.20DF, 1,  "%d"},
-  {__LINE__, DEC_NAN, 1,  "%d"},
+  {__LINE__, DEC_NAN, 0,  "%d"},
   {__LINE__, HUGE_VAL_D32, 0, "%d"},
   {__LINE__, DEC_INFINITY, 0, "%d"},
-  {__LINE__, -1.95DF, 1, "%d"},
+  {__LINE__, -1.95DF, -1, "%d"},
   {0,0,0,0 }
 };
 

Modified: libdfp/trunk/tests/test-logd.c
==============================================================================
--- libdfp/trunk/tests/test-logd.c (original)
+++ libdfp/trunk/tests/test-logd.c Fri Jul 23 10:20:29 2010
@@ -65,16 +65,18 @@
   const char *expect;
 } d64_decode_type;
 
-const char DECLET_DEC_NAN[] = "-0,000,000,000,000,010E-1";
+const char DECLET32_NAN[] = "+0,000,000E-101";
+const char DECLET64_NAN[] = "+0,000,000,000,000,000E-398";
+const char DECLET128_NAN[] = "+0,000,000,000,000,000,000,000,000,000,000,000E-6176";
 
 d64_decode_type decode_d64s[] =
 {
   /* DEC_NAN is +0,000,000,000,000,000E-398 so test against that
    * since you can't compare DEC_NAN to DEC_NAN.  */
-  {__LINE__, -1.0DD, DECLET_DEC_NAN},
+  {__LINE__, -1.0DD, DECLET64_NAN},
   //{__LINE__, -1.0DD, "-0,000,000,000,000,010E-1"},
 #ifdef _ARCH_PWR6 /* This returns NaN in the hard-DFP case.  */
-  {__LINE__, __DEC64_MAX__, DECLET_DEC_NAN},
+  {__LINE__, __DEC64_MAX__, DECLET64_NAN},
 #endif
   {0,0,0 }
 };

Modified: libdfp/trunk/tests/test-strtod.c
==============================================================================
--- libdfp/trunk/tests/test-strtod.c (original)
+++ libdfp/trunk/tests/test-strtod.c Fri Jul 23 10:20:29 2010
@@ -74,13 +74,13 @@
   for (dptr = strtods; dptr->line; dptr++)
     {
 
-      fprintf(stderr, "  strtod32(\"%s\",NULL) == %Hf\n  ", dptr->input, strtod32(dptr->input, NULL));
+      fprintf(stdout, "strtod32(\"%s\",NULL) == %Hf\n  ", dptr->input, strtod32(dptr->input, NULL));
       _VC_P(__FILE__,dptr->line,dptr->d32,strtod32(dptr->input,NULL), "%Hf");
 
-      fprintf(stderr, "  strtod64(\"%s\",NULL) == %Df\n  ", dptr->input, strtod64(dptr->input, NULL));
+      fprintf(stdout, "strtod64(\"%s\",NULL) == %Df\n  ", dptr->input, strtod64(dptr->input, NULL));
       _VC_P(__FILE__,dptr->line,dptr->d64, strtod64(dptr->input,NULL), "%Df");
 
-      fprintf(stderr, "  strtod128(\"%s\",NULL) == %DDf\n  ", dptr->input, strtod128(dptr->input, NULL));
+      fprintf(stdout, "strtod128(\"%s\",NULL) == %DDf\n  ", dptr->input, strtod128(dptr->input, NULL));
       _VC_P(__FILE__,dptr->line,dptr->d128, strtod128(dptr->input,NULL), "%DDf");
     }