This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Fix log (1) in round-downward mode (bug 16731)
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Adam Conrad <adconrad at 0c3 dot net>
- Cc: <libc-alpha at sourceware dot org>, <aurelien at aurel32 dot net>
- Date: Fri, 21 Mar 2014 22:31:24 +0000
- Subject: Re: Fix log (1) in round-downward mode (bug 16731)
- Authentication-results: sourceware.org; auth=none
- References: <Pine dot LNX dot 4 dot 64 dot 1403211746350 dot 4557 at digraph dot polyomino dot org dot uk> <20140321201111 dot GA21819 at 0c3 dot net>
On Fri, 21 Mar 2014, Adam Conrad wrote:
> On Fri, Mar 21, 2014 at 05:47:45PM +0000, Joseph S. Myers wrote:
> > According to ISO C Annex F, log (1) should be +0 in all rounding
> > modes, but some implementations in glibc wrongly return -0 in
> > round-downward mode (mapping to log1p (x - 1) is problematic because 1
> > - 1 is -0 in round-downward mode, and log1p (-0) is -0). This patch
> > fixes this. (It helps with some implementations of other functions
> > such as acosh, log2 and log10 that call out to log, but not enough to
> > enable all-rounding-modes testing for those functions without further
> > fixes to other implementations of them.)
>
> This reminds me (in context) of this patch we're carrying in Debian:
>
> http://anonscm.debian.org/viewvc/pkg-glibc/glibc-package/trunk/debian/patches/powerpc/local-math-logb.diff?revision=5951&view=markup
>
> If I recall, Aurelien said we're carrying it locally because it was
> rejected upstream as not a bug, due to it only affecting older HW
> that no one cares about.
>
> Should we be cleaning this up and re-submitting, to go along with
> your batch of fixes here?
What I think should be done here is:
* Submit a bug to GCC Bugzilla about conversion from integer to floating
point being incorrect for older hard-float powerpc with -frounding-math.
* Reopen bug 887 as not in fact fixed, and remove it from the list of bugs
fixed in 2.16 in NEWS.
* Close bug 16423 as a duplicate of the newly reopened bug 887.
* Work around the GCC bug in glibc conditional on a configure test for
whether (building for powerpc and) $CC $CFLAGS $CPPFLAGS -frounding-math
generates the problem code sequence (i.e. the one involving certain magic
constants and floating-point addition / subtraction), not using fcfid, not
using any instructions to save / restore the rounding mode (the last bit
may be more difficult to test for in a future-proof way, since you don't
know what any fix for the GCC bug might look like). Make sure comments
reference the GCC bug in question.
* Having got such a workaround in glibc, bug 887 can then be closed as
fixed.
--
Joseph S. Myers
joseph@codesourcery.com