This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Fix powerpc32 llrint, llrintf bad exceptions (bug 16422) [committed]
- From: Steven Munroe <munroesj at linux dot vnet dot ibm dot com>
- To: Joseph Myers <joseph at codesourcery dot com>, Tulio Machado <tuliom at linux dot vnet dot ibm dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Mon, 12 Oct 2015 22:25:18 -0500
- Subject: Re: Fix powerpc32 llrint, llrintf bad exceptions (bug 16422) [committed]
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 10 dot 1510130053350 dot 4306 at digraph dot polyomino dot org dot uk>
- Reply-to: munroesj at linux dot vnet dot ibm dot com
On Tue, 2015-10-13 at 00:53 +0000, Joseph Myers wrote:
> The versions of llrint and llrintf for older powerpc32 processors
> convert the results of __rint / __rintf to long long int, resulting in
> spurious exceptions from such casts in certain cases. This patch
> makes glibc work around the problems with the libgcc conversions when
> the compiler used to build glibc doesn't use the fctidz instruction
> for them.
>
> Tested for powerpc. Committed.
Thanks Joseph for looking at this.
This look correct as is, but I wonder if we find a way to avoid both the
__rint/__rintf call and the fctidz (trunc & concert) in the normal path.
The __rint implementations requires a -fPIC GOT address set up just to
load a single constant. This is unfortunate as the calling function
(llrint/llrintf) will have just done that.
Also the fctid instruction will do the llrint function in one
instruction and records NAN, overflow, as special values in the result
and inexact in the FPSRC and CR1 (record form).
The primary reason it was not used here was that early 32-bit PPC32
processors did not implement fctid.
As Joseph has gone to the trouble to provide the configure check for
HAVE_PPC_FCFID it seems like shame not to take advantage of it.
Tulio we should look at this again when we have time.