This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: PowerPC, lroundl bug
- From: "Ryan Arnold" <ryan dot arnold at gmail dot com>
- To: "Przemyslaw Iskra" <sparky at pld-linux dot org>
- Cc: libc-alpha at sourceware dot org
- Date: Wed, 1 Oct 2008 11:23:05 -0500
- Subject: Re: PowerPC, lroundl bug
- References: <20081001154243.GA7398@pld-linux.org>
On Wed, Oct 1, 2008 at 10:42 AM, Przemyslaw Iskra <sparky@pld-linux.org> wrote:
> Hi.
>
> PowerPC assembler implementations of lroundl and llroundl functions use
> cr3 and cr4 (which are non-volatile) without saving them. This brakes
> some more complex code which requires those cr fields to be preserved.
>
> [sparky@pepec glibc-2.8]$ find sysdeps/powerpc -name "s_*lround.S" | xargs grep cr3
> sysdeps/powerpc/powerpc32/fpu/s_lround.S: fcmpu cr3, fp1, fp12 /* x is negative? x < 0.0 */
> sysdeps/powerpc/powerpc32/fpu/s_lround.S: bge cr3,.Lconvert /* x is positive so don't negate x. */
> sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S: fcmpu cr3,fp1,fp12 /* x is negative? x < 0.0 */
> sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S: bge cr3,.Lconvert /* x is positive so don't negate x. */
> sysdeps/powerpc/powerpc64/fpu/s_llround.S: fcmpu cr3,fp1,fp12 /* x is negative? x < 0.0 */
> sysdeps/powerpc/powerpc64/fpu/s_llround.S: bge cr3,.Lconvert /* x is positive so don't negate x. */
>
> [sparky@pepec glibc-2.8]$ find sysdeps/powerpc -name "s_*lround.S" | xargs grep cr4
> sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S: fcmpu cr4,fp2,fp9 /* if |x| >= 2^52 */
> sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S: bge- cr4,.Lnobias /* 2^52 > x < -2^52 just convert with no bias. */
> sysdeps/powerpc/powerpc64/fpu/s_llround.S: fcmpu cr4,fp2,fp9 /* if |x| >= 2^52 */
> sysdeps/powerpc/powerpc64/fpu/s_llround.S: bge- cr4,.Lnobias /* 2^52 > x < -2^52 just convert with no bias. */
>
> [sparky@pepec glibc-2.8]$ find sysdeps/powerpc -name "s_*lround.S" | xargs grep mfcr
>
> [sparky@pepec glibc-2.8]$
>
>
> I can post the patch to fix it, but maybe someone should take a deeper
> look how the broken code could get into glibc source.
Yep, this was my bad.
Jakub applied the fix you see in the following libc-hacker post in June:
http://www.sourceware.org/ml/libc-hacker/2008-06/msg00001.html
regards,
Ryan S. Arnold