This is sources Bugzilla
Bugzilla Version 2.17.5
Bugzilla Bug 2423
  Errors in long double (ldbl-128ibm) rounding functions in glibc-2.4 Last modified: 2007-02-18 13:54:11
     Query page      Enter new bug
Bug#: 2423   Hardware:   Reporter: Steven Munroe <sjmunroe@us.ibm.com>
Host: Target: Build:
Product:     Add CC:
Component:   Version:   CC:
Remove selected CCs
Status: RESOLVED   Priority:  
Resolution: FIXED   Severity:  
Assigned To: Andreas Jaeger <aj@suse.de>   Target Milestone:  
Flags: Requestee:
  backport ()
  examined ()
  testsuite ()
Summary:
Keywords:

Attachment Description Type Created Actions
test-rintl.out Sample of error output. text/plain 2006-03-06 20:44 Edit None
test-ldrounding.tgz Standalone test cases. text/plain 2006-03-06 20:48 Edit None
ppc-ldround-20060303.txt Proposed patch patch 2006-03-06 20:55 Edit | Diff
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 2423 depends on: Show dependency tree
Show dependency graph
Bug 2423 blocks:

Additional Comments:


Leave as RESOLVED FIXED
Reopen bug
Mark bug as VERIFIED

View Bug Activity   |   Format For Printing


Description:   Last confirmed: 0000-00-00 00:00 Opened: 2006-03-06 20:29
The implementations of the (IBM double double format) long double
(./ldbld-128ibm/) for ceill, floorl, rintl, roundl, truncl, rounds incorrectly
when the integer portion is contained in th ehigh double, but the fractional
postion is contained in the low double.

------- Additional Comment #1 From Steven Munroe 2006-03-06 20:44 -------
Created an attachment (id=904)
Sample of error output.

------- Additional Comment #2 From Steven Munroe 2006-03-06 20:48 -------
Created an attachment (id=905)
Standalone test cases.

------- Additional Comment #3 From Steven Munroe 2006-03-06 20:55 -------
Created an attachment (id=906)
Proposed patch

Proposed patch for ./ldbl-128ibm/ implementations of ceill, floorl, rintl,
roundl, truncl

------- Additional Comment #4 From cvs-commit@gcc.gnu.org 2006-03-07 08:24 -------
Subject: Bug 2423

CVSROOT:	/cvs/glibc
Module name:	libc
Branch: 	fedora-branch
Changes by:	jakub@sources.redhat.com	2006-03-07 08:24:13

Modified files:
	.              : ChangeLog 
	math           : libm-test.inc 
	sysdeps/ieee754/ldbl-128ibm: e_fmodl.c e_rem_pio2l.c math_ldbl.h 
	                             s_ceill.c s_floorl.c s_rintl.c 
	                             s_roundl.c s_truncl.c 
	sysdeps/powerpc/fpu: fegetround.c fenv_libc.h fesetround.c 
Added files:
	sysdeps/powerpc/fpu: math_ldbl.h 

Log message:
	2006-03-03  Steven Munroe  <sjmunroe@us.ibm.com>
	Alan Modra  <amodra@bigpond.net.au>
	
	[BZ #2423]
	* math/libm-test.inc [TEST_LDOUBLE] (ceil_test, floor_test, rint_test,
	round_test, trunc_test): Add new tests.
	
	* sysdeps/powerpc/fpu/fenv_libc.h (__fegetround, __fesetround):
	Define inline implementations.
	* sysdeps/powerpc/fpu/fegetround.c: Use __fegetround.
	* sysdeps/powerpc/fpu/fesetround.c: Use __fesetround.
	
	* sysdeps/ieee754/ldbl-128ibm/math_ldbl.h
	(EXTRACT_IBM_EXTENDED_MANTISSA, INSERT_IBM_EXTENDED_MANTISSA):
	Removed, replaced with.
	(ldbl_extract_mantissa, ldbl_insert_mantissa, ldbl_pack, ldbl_unpack,
	ldbl_canonicalise, ldbl_nearbyint): Define inline utility
	functions for IBM long double format.
	* sysdeps/ieee754/ldbl-128ibm/e_fmodl.c (__ieee754_fmodl): Replace
	EXTRACT_IBM_EXTENDED_MANTISSA and INSERT_IBM_EXTENDED_MANTISSA
	with ldbl_extract_mantissa and ldbl_insert_mantissa.
	* sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c (__ieee754_rem_pio2l):
	Replace EXTRACT_IBM_EXTENDED_MANTISSA with ldbl_extract_mantissa.
	(ldbl_extract_mantissa, ldbl_insert_mantissa): Defined.
	
	* sysdeps/ieee754/ldbl-128ibm/s_ceill.c (__ceill): Handle rounding
	that spans doubles in IBM long double format.
	* sysdeps/ieee754/ldbl-128ibm/s_floorl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_rintl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_roundl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_truncl.c: Likewise.
	* sysdeps/powerpc/fpu/math_ldbl.h: New file.
	* sysdeps/powerpc/powerpc64/fpu/s_rintl.S: Removed.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/ChangeLog.diff?cvsroot=glibc&only_with_tag=fedora-branch&r1=1.8782.2.172&r2=1.8782.2.173
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/math/libm-test.inc.diff?cvsroot=glibc&only_with_tag=fedora-branch&r1=1.61.2.6&r2=1.61.2.7
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/e_fmodl.c.diff?cvsroot=glibc&only_with_tag=fedora-branch&r1=1.1.2.1&r2=1.1.2.2
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c.diff?cvsroot=glibc&only_with_tag=fedora-branch&r1=1.1.2.1&r2=1.1.2.2
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/math_ldbl.h.diff?cvsroot=glibc&only_with_tag=fedora-branch&r1=1.1.2.1&r2=1.1.2.2
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/s_ceill.c.diff?cvsroot=glibc&only_with_tag=fedora-branch&r1=1.1.2.2&r2=1.1.2.3
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/s_floorl.c.diff?cvsroot=glibc&only_with_tag=fedora-branch&r1=1.1.2.2&r2=1.1.2.3
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/s_rintl.c.diff?cvsroot=glibc&only_with_tag=fedora-branch&r1=1.1.2.1&r2=1.1.2.2
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/s_roundl.c.diff?cvsroot=glibc&only_with_tag=fedora-branch&r1=1.1.2.1&r2=1.1.2.2
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/s_truncl.c.diff?cvsroot=glibc&only_with_tag=fedora-branch&r1=1.1.2.1&r2=1.1.2.2
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/powerpc/fpu/math_ldbl.h.diff?cvsroot=glibc&only_with_tag=fedora-branch&r1=NONE&r2=1.1.2.1
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/powerpc/fpu/fegetround.c.diff?cvsroot=glibc&only_with_tag=fedora-branch&r1=1.2&r2=1.2.4.1
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/powerpc/fpu/fenv_libc.h.diff?cvsroot=glibc&only_with_tag=fedora-branch&r1=1.2&r2=1.2.4.1
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/powerpc/fpu/fesetround.c.diff?cvsroot=glibc&only_with_tag=fedora-branch&r1=1.3.4.1&r2=1.3.4.2


------- Additional Comment #5 From cvs-commit@gcc.gnu.org 2006-03-16 11:46 -------
Subject: Bug 2423

CVSROOT:	/cvs/glibc
Module name:	libc
Changes by:	roland@sources.redhat.com	2006-03-16 11:46:30

Modified files:
	math           : libm-test.inc 

Log message:
	2006-03-07  Jakub Jelinek  <jakub@redhat.com>
	
	[BZ #2423]
	* math/libm-test.inc [TEST_LDOUBLE] (ceil_test, floor_test, rint_test,
	round_test, trunc_test): Only run some of the new tests if
	LDBL_MANT_DIG > 100.
	2006-03-03  Steven Munroe  <sjmunroe@us.ibm.com> Alan Modra  <amodra@bigpond.net.au>
	
	[BZ #2423]
	* math/libm-test.inc [TEST_LDOUBLE] (ceil_test, floor_test, rint_test,
	round_test, trunc_test): Add new tests.
	* sysdeps/ieee754/ldbl-128ibm/math_ldbl.h
	(EXTRACT_IBM_EXTENDED_MANTISSA, INSERT_IBM_EXTENDED_MANTISSA):
	Removed, replaced with ...
	(ldbl_extract_mantissa, ldbl_insert_mantissa, ldbl_pack, ldbl_unpack,
	ldbl_canonicalise, ldbl_nearbyint): New functions.
	* sysdeps/ieee754/ldbl-128ibm/e_fmodl.c (__ieee754_fmodl): Replace
	EXTRACT_IBM_EXTENDED_MANTISSA and INSERT_IBM_EXTENDED_MANTISSA
	with ldbl_extract_mantissa and ldbl_insert_mantissa.
	* sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c (__ieee754_rem_pio2l):
	Replace EXTRACT_IBM_EXTENDED_MANTISSA with ldbl_extract_mantissa.
	(ldbl_extract_mantissa, ldbl_insert_mantissa): New inline functions.
	* sysdeps/ieee754/ldbl-128ibm/s_ceill.c (__ceill): Handle rounding
	that spans doubles in IBM long double format.
	* sysdeps/ieee754/ldbl-128ibm/s_floorl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_rintl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_roundl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_truncl.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_rintl.S: File removed.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/math/libm-test.inc.diff?cvsroot=glibc&r1=1.69&r2=1.70


------- Additional Comment #6 From cvs-commit@gcc.gnu.org 2006-03-16 11:46 -------
Subject: Bug 2423

CVSROOT:	/cvs/glibc
Module name:	libc
Changes by:	roland@sources.redhat.com	2006-03-16 11:46:37

Modified files:
	sysdeps/ieee754/ldbl-128ibm: s_ceill.c s_floorl.c s_rintl.c 
	                             math_ldbl.h e_rem_pio2l.c e_fmodl.c 
	                             s_truncl.c s_roundl.c 
Removed files:
	sysdeps/powerpc/powerpc64/fpu: s_rintl.S 

Log message:
	2006-03-03  Steven Munroe  <sjmunroe@us.ibm.com> Alan Modra  <amodra@bigpond.net.au>
	
	[BZ #2423]
	* math/libm-test.inc [TEST_LDOUBLE] (ceil_test, floor_test, rint_test,
	round_test, trunc_test): Add new tests.
	* sysdeps/ieee754/ldbl-128ibm/math_ldbl.h
	(EXTRACT_IBM_EXTENDED_MANTISSA, INSERT_IBM_EXTENDED_MANTISSA):
	Removed, replaced with ...
	(ldbl_extract_mantissa, ldbl_insert_mantissa, ldbl_pack, ldbl_unpack,
	ldbl_canonicalise, ldbl_nearbyint): New functions.
	* sysdeps/ieee754/ldbl-128ibm/e_fmodl.c (__ieee754_fmodl): Replace
	EXTRACT_IBM_EXTENDED_MANTISSA and INSERT_IBM_EXTENDED_MANTISSA
	with ldbl_extract_mantissa and ldbl_insert_mantissa.
	* sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c (__ieee754_rem_pio2l):
	Replace EXTRACT_IBM_EXTENDED_MANTISSA with ldbl_extract_mantissa.
	(ldbl_extract_mantissa, ldbl_insert_mantissa): New inline functions.
	* sysdeps/ieee754/ldbl-128ibm/s_ceill.c (__ceill): Handle rounding
	that spans doubles in IBM long double format.
	* sysdeps/ieee754/ldbl-128ibm/s_floorl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_rintl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_roundl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_truncl.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_rintl.S: File removed.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/powerpc/powerpc64/fpu/s_rintl.S.diff?cvsroot=glibc&r1=1.1&r2=NONE
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/s_ceill.c.diff?cvsroot=glibc&r1=1.2&r2=1.3
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/s_floorl.c.diff?cvsroot=glibc&r1=1.2&r2=1.3
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/s_rintl.c.diff?cvsroot=glibc&r1=1.1&r2=1.2
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/math_ldbl.h.diff?cvsroot=glibc&r1=1.1&r2=1.2
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c.diff?cvsroot=glibc&r1=1.1&r2=1.2
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/e_fmodl.c.diff?cvsroot=glibc&r1=1.1&r2=1.2
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/s_truncl.c.diff?cvsroot=glibc&r1=1.1&r2=1.2
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/s_roundl.c.diff?cvsroot=glibc&r1=1.1&r2=1.2


------- Additional Comment #7 From Ulrich Drepper 2006-04-23 17:43 -------
You cannot change the rounding mode in library functions.  This would make using
floating point operations in signal handlers unpredictable.

------- Additional Comment #8 From Steven Munroe 2006-05-11 13:55 -------
hmmm, the alternative is to simulate the operation with integer ops. But this is
generic code...

I'll look to using the double rounding equivelent, instead of changing the
rounding mode inline, to get the desired effect. Slightly less efficient but
more  general.

------- Additional Comment #9 From Steven Munroe 2006-06-14 18:29 -------
hhhmm its harder then I thought. The IBM extended format ABI states clearly that
it only works correctly in the default rounding mode (round to nearest). 

Given that assumption it, seems unnecessary to guard against the user changing
the rounding to a non-default mode, as basic arithmatic and canonicalization may
be incorrect anyway.

So it seems the best solution is to simply remove the fesetround where possible.
This works for ceill, floorl, roundl, and truncl as they are never tested in the
non-default rounding mode. llroundl is clean because it is only using
feraiseexcept (handle overflow) and does not mess with rounding.

This also helps with Bugzilla 2749 as soft-fp does not provide fenv_libc.h. We
need to either remove the #include <fenv_libc.h> and any related fe* calls, or
replace <fenv_libc.h> with <fenv.h>

llrintl and rintl are another matter as these are explictly tested in all
rounding modes (and yes I did this to myself :( ). 

At the moment I don't have a good answer for these yet other then disabling the
non-default rounding mode tests for IBM extended.

------- Additional Comment #10 From cvs-commit@gcc.gnu.org 2007-01-17 13:00 -------
Subject: Bug 2423

CVSROOT:	/cvs/glibc
Module name:	libc
Changes by:	jakub@sourceware.org	2007-01-17 13:00:11

Modified files:
	.              : ChangeLog 
	sysdeps/ieee754/ldbl-128ibm: s_fabsl.c s_roundl.c s_truncl.c 
	                             s_copysignl.c s_ceill.c s_floorl.c 

Log message:
	[BZ #2749]
	* sysdeps/ieee754/ldbl-128ibm/s_copysignl.c: Include
	<math_ldbl_opt.h>.  Remove weak_alias.  Use long_double_symbol macro.
	(__copysignl): Use signbit() for comparison.
	* sysdeps/ieee754/ldbl-128ibm/s_fabsl.c (__fabsl): Correct parms for
	SET_LDOUBLE_WORDS64.
	
	[BZ #2423, #2749]
	* sysdeps/ieee754/ldbl-128ibm/s_ceill.c: Don't include <fenv_libc.h>.
	(__ceill): Remove calls to fegetround(), fesetround().
	* sysdeps/ieee754/ldbl-128ibm/s_floorl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_roundl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_truncl.c: Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/ChangeLog.diff?cvsroot=glibc&r1=1.10480&r2=1.10481
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/s_fabsl.c.diff?cvsroot=glibc&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/s_roundl.c.diff?cvsroot=glibc&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/s_truncl.c.diff?cvsroot=glibc&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/s_copysignl.c.diff?cvsroot=glibc&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/s_ceill.c.diff?cvsroot=glibc&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/sysdeps/ieee754/ldbl-128ibm/s_floorl.c.diff?cvsroot=glibc&r1=1.3&r2=1.4


------- Additional Comment #11 From Andreas Jaeger 2007-02-18 13:54 -------
should be fixed now.

     Query page      Enter new bug
Actions: New | Query | bug # | Reports | Requests   New Account | Log In