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]

Re: Fix powerpc32 llrint, llrintf bad exceptions (bug 16422) [committed]


On Mon, 12 Oct 2015, Steven Munroe wrote:

> 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.

If you configure --with-cpu=power4 then you get versions from 
sysdeps/powerpc/powerpc32/power4/fpu which do just that using fctid.  I 
suppose the issues are:

(a) the GCC condition for TARGET_FCFID is quite complicated and may 
include some cases for which use of the power4 sysdeps directories isn't 
correct (because of other files there - I haven't checked);

(b) while we have a desired direction for building glibc to choose sysdeps 
directories based on how the compiler behaves (see what 
sysdeps/arm/preconfigure.ac does), preferring that over glibc --with-cpu=, 
that hasn't been implemented for powerpc, so meaning that even if the 
compiler was configured with a power4 or later default and so use of the 
power4 sysdeps directories would be safe, glibc wouldn't use them without 
its own --with-cpu= configure option;

(c) if both implementations were in C then it would be possible for the 
default one to do

#if HAVE_PPC_FCTIDZ
# include <sysdeps/...../power4/fpu/s_llrint.c>
#else
/* Other implementation.  */
#endif

but with one in C and one in assembler it's a bit more complicated, though 
that could still be done with extra source files (but given (b) it's only 
worthwhile if there are in fact cases where those implementations can be 
used but not the whole power4 sysdeps directory).

-- 
Joseph S. Myers
joseph@codesourcery.com


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