This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] [BZ #2749] soft-fp fixes, update


I updated this patch to current glibc cvs trunk and move fenv-libc.h to  sysdeps/powerpc/nofpu/ as suggested by Jakub.

It is clear that rounding a inf or NAN makes no sense and is wasted effort, so I left the 
_FP_PACK_SEMIRAW patch unchanged.

This patch corrects functional issues we found in the soft-fp implementation that are common to all arches using soft-fp. We need to get these patches into libc trunk, so we can migrate them into the soft-fp implementation of gcc mainline.

2007-01-12  Steven Munroe  <sjmunroe@us.ibm.com>
	    Joe Kerian  <jkerian@us.us.ibm.com>

	[BZ #2749]
	* soft-fp/op-4.h (__FP_FRAC_SUB_3, __FP_FRAC_SUB_4): Correct borrow
	handling for high words.
	* soft-fp/op-common.h (_FP_OVERFLOW_SEMIRAW): Always set inexact
	and overflow for infinity.
	(_FP_PACK_SEMIRAW): Update comment.  Do not round if NaN.
	* sysdeps/powerpc/nofpu/fenv_libc.h: New file.

diff -urN libc25-cvstip-20070104/soft-fp/op-4.h libc24/soft-fp/op-4.h
--- libc25-cvstip-20070104/soft-fp/op-4.h	2006-04-04 03:24:47.000000000 -0500
+++ libc24/soft-fp/op-4.h	2007-01-11 11:00:53.082820752 -0600
@@ -564,7 +564,7 @@
     r1 = x1 - y1;						\
     _c2 = r1 > x1;						\
     r1 -= _c1;							\
-    _c2 |= r1 > _c1;						\
+    _c2 |= _c1 && (y1 == x1);					\
     r2 = x2 - y2 - _c2;						\
   } while (0)
 #endif
@@ -578,11 +578,11 @@
     r1 = x1 - y1;						\
     _c2 = r1 > x1;						\
     r1 -= _c1;							\
-    _c2 |= r1 > _c1;						\
+    _c2 |= _c1 && (y1 == x1);					\
     r2 = x2 - y2;						\
     _c3 = r2 > x2;						\
     r2 -= _c2;							\
-    _c3 |= r2 > _c2;						\
+    _c3 |= _c2 && (y2 == x2);					\
     r3 = x3 - y3 - _c3;						\
   } while (0)
 #endif
diff -urN libc25-cvstip-20070104/soft-fp/op-common.h libc24/soft-fp/op-common.h
--- libc25-cvstip-20070104/soft-fp/op-common.h	2006-04-04 03:24:47.000000000 -0500
+++ libc24/soft-fp/op-common.h	2007-01-11 17:17:17.301821864 -0600
@@ -99,10 +99,10 @@
   else							\
     {							\
       X##_e = _FP_EXPMAX_##fs - 1;			\
-      FP_SET_EXCEPTION(FP_EX_OVERFLOW);			\
-      FP_SET_EXCEPTION(FP_EX_INEXACT);			\
       _FP_FRAC_SET_##wc(X, _FP_MAXFRAC_##wc);		\
     }							\
+    FP_SET_EXCEPTION(FP_EX_INEXACT);			\
+    FP_SET_EXCEPTION(FP_EX_OVERFLOW);			\
 } while (0)
 
 /* Check for a semi-raw value being a signaling NaN and raise the
@@ -131,10 +131,12 @@
 
 /* Prepare to pack an fp value in semi-raw mode: the mantissa is
    rounded and shifted right, with the rounding possibly increasing
-   the exponent (including changing a finite value to infinity).  */
+   the exponent (including changing a finite value to infinity).
+   Be sure not to round NaNs.  */
 #define _FP_PACK_SEMIRAW(fs, wc, X)				\
 do {								\
-  _FP_ROUND(wc, X);						\
+  if(X##_e != _FP_EXPMAX_##fs)					\
+    _FP_ROUND(wc, X);						\
   if (_FP_FRAC_HIGH_##fs(X)					\
       & (_FP_OVERFLOW_##fs >> 1))				\
     {								\
diff -urN libc25-cvstip-20070104/sysdeps/powerpc/nofpu/fenv_libc.h libc24/sysdeps/powerpc/nofpu/fenv_libc.h
--- libc25-cvstip-20070104/sysdeps/powerpc/nofpu/fenv_libc.h	Wed Dec 31 18:00:00 1969
+++ libc24/sysdeps/powerpc/nofpu/fenv_libc.h	Thu Jan 11 11:00:53 2007
@@ -0,0 +1,29 @@
+/* Internal libc stuff for floating point environment routines.
+   Copyright (C) 2006 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _FENV_LIBC_H
+#define _FENV_LIBC_H	1
+
+/* fenv_libc.h is used in libm implementations of ldbl-128ibm.  So we
+   need this version in the soft-fp to at minimum include fenv.h to
+   get the fegetround definition.  */
+
+#include <fenv.h>
+ 
+#endif /* fenv_libc.h */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]