From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10588 invoked by alias); 12 Jun 2008 19:18:38 -0000 Received: (qmail 10572 invoked by uid 22791); 12 Jun 2008 19:18:37 -0000 X-Spam-Check-By: sourceware.org Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 12 Jun 2008 19:18:20 +0000 Received: from sunsite.mff.cuni.cz (localhost.localdomain [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.8/8.13.8) with ESMTP id m5CJTZAd030449; Thu, 12 Jun 2008 21:29:35 +0200 Received: (from jakub@localhost) by sunsite.mff.cuni.cz (8.13.8/8.13.8/Submit) id m5CJTYNx030448; Thu, 12 Jun 2008 21:29:34 +0200 Date: Thu, 12 Jun 2008 19:18:00 -0000 From: Jakub Jelinek To: Ulrich Drepper , Steven Munroe , David Woodhouse Cc: Glibc hackers Subject: [PATCH] Avoid clobbering call-saved cr registers in ppc hand written assembly Message-ID: <20080612192933.GA3726@sunsite.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2008-06/txt/msg00001.txt.bz2 Hi! gcc says: cr7, cr6 (not saved or special) cr1 (not saved, but used for FP operations) cr0 (not saved, but used for arithmetic operations) cr4, cr3, cr2 (saved) ... cr5, r1, r2, ap, xer (fixed) But apparently some *lround* routines set cr[34] registers, which are call-saved. This causes e.g. http://bugzilla.redhat.com/450790 >From the above I believe using cr1 and cr7 instead of cr3 and cr4 should be ok (though the patch is untested). 2008-06-12 Jakub Jelinek * sysdeps/powerpc/powerpc64/fpu/s_llround.S (__llround): Avoid using cr[34] registers. * sysdeps/powerpc/powerpc64/fpu/s_llroundf.S (__llroundf): Likewise. * sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S (__llround): Likewise. * sysdeps/powerpc/powerpc32/fpu/s_lround.S (__lround): Avoid using cr3 register. --- libc/sysdeps/powerpc/powerpc64/fpu/s_llround.S.jj 2008-04-17 10:32:49.000000000 +0200 +++ libc/sysdeps/powerpc/powerpc64/fpu/s_llround.S 2008-06-12 20:53:40.000000000 +0200 @@ -1,5 +1,5 @@ /* llround function. PowerPC64 version. - Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -52,12 +52,12 @@ ENTRY (__llround) fabs fp2,fp1 /* Get the absolute value of x. */ fsub fp12,fp10,fp10 /* Compute 0.0 into fp12. */ fcmpu cr6,fp2,fp10 /* if |x| < 0.5 */ - fcmpu cr4,fp2,fp9 /* if |x| >= 2^52 */ - fcmpu cr3,fp1,fp12 /* x is negative? x < 0.0 */ + fcmpu cr7,fp2,fp9 /* if |x| >= 2^52 */ + fcmpu cr1,fp1,fp12 /* x is negative? x < 0.0 */ blt- cr6,.Lretzero /* 0.5 > x < -0.5 so just return 0. */ - bge- cr4,.Lnobias /* 2^52 > x < -2^52 just convert with no bias. */ + bge- cr7,.Lnobias /* 2^52 > x < -2^52 just convert with no bias. */ fadd fp3,fp2,fp10 /* |x|+=0.5 bias to prepare to round. */ - bge cr3,.Lconvert /* x is positive so don't negate x. */ + bge cr1,.Lconvert /* x is positive so don't negate x. */ fnabs fp3,fp3 /* -(|x|+=0.5) */ .Lconvert: fctidz fp4,fp3 /* Convert to Integer double word round toward 0. */ --- libc/sysdeps/powerpc/powerpc64/fpu/s_llroundf.S.jj 2008-04-17 10:32:49.000000000 +0200 +++ libc/sysdeps/powerpc/powerpc64/fpu/s_llroundf.S 2008-06-12 20:54:17.000000000 +0200 @@ -1,5 +1,5 @@ /* llroundf function. PowerPC64 version. - Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -51,12 +51,12 @@ ENTRY (__llroundf) fabs fp2,fp1 /* Get the absolute value of x. */ fsub fp12,fp10,fp10 /* Compute 0.0 into fp12. */ fcmpu cr6,fp2,fp10 /* if |x| < 0.5 */ - fcmpu cr4,fp2,fp9 /* if |x| >= 2^23 */ - fcmpu cr3,fp1,fp12 /* x is negative? x < 0.0 */ + fcmpu cr7,fp2,fp9 /* if |x| >= 2^23 */ + fcmpu cr1,fp1,fp12 /* x is negative? x < 0.0 */ blt- cr6,.Lretzero /* 0.5 > x < -0.5 so just return 0. */ - bge- cr4,.Lnobias /* 2^23 > x < -2^23 just convert with no bias. */ + bge- cr7,.Lnobias /* 2^23 > x < -2^23 just convert with no bias. */ fadd fp3,fp2,fp10 /* |x|+=0.5 bias to prepare to round. */ - bge cr3,.Lconvert /* x is positive so don't negate x. */ + bge cr1,.Lconvert /* x is positive so don't negate x. */ fnabs fp3,fp3 /* -(|x|+=0.5) */ .Lconvert: fctidz fp4,fp3 /* Convert to Integer double word round toward 0. */ --- libc/sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S.jj 2008-04-17 10:32:49.000000000 +0200 +++ libc/sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S 2008-06-12 20:54:50.000000000 +0200 @@ -1,5 +1,5 @@ /* llround function. PowerPC32 on PowerPC64 version. - Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -75,12 +75,12 @@ ENTRY (__llround) fabs fp2,fp1 /* Get the absolute value of x. */ fsub fp12,fp10,fp10 /* Compute 0.0 into fpr12. */ fcmpu cr6,fp2,fp10 /* if |x| < 0.5 */ - fcmpu cr4,fp2,fp9 /* if |x| >= 2^52 */ - fcmpu cr3,fp1,fp12 /* x is negative? x < 0.0 */ + fcmpu cr7,fp2,fp9 /* if |x| >= 2^52 */ + fcmpu cr1,fp1,fp12 /* x is negative? x < 0.0 */ blt- cr6,.Lretzero /* 0.5 > x < -0.5 so just return 0. */ - bge- cr4,.Lnobias /* 2^52 > x < -2^52 just convert with no bias. */ + bge- cr7,.Lnobias /* 2^52 > x < -2^52 just convert with no bias. */ fadd fp3,fp2,fp10 /* |x|+=0.5 bias to prepare to round. */ - bge cr3,.Lconvert /* x is positive so don't negate x. */ + bge cr1,.Lconvert /* x is positive so don't negate x. */ fnabs fp3,fp3 /* -(|x|+=0.5) */ .Lconvert: fctidz fp4,fp3 /* Convert to Integer double word round toward 0. */ --- libc/sysdeps/powerpc/powerpc32/fpu/s_lround.S.jj 2008-04-17 10:32:49.000000000 +0200 +++ libc/sysdeps/powerpc/powerpc32/fpu/s_lround.S 2008-06-12 20:55:16.000000000 +0200 @@ -1,5 +1,5 @@ /* lround function. PowerPC32 version. - Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -65,10 +65,10 @@ ENTRY (__lround) fabs fp2, fp1 /* Get the absolute value of x. */ fsub fp12,fp10,fp10 /* Compute 0.0. */ fcmpu cr6, fp2, fp10 /* if |x| < 0.5 */ - fcmpu cr3, fp1, fp12 /* x is negative? x < 0.0 */ + fcmpu cr7, fp1, fp12 /* x is negative? x < 0.0 */ blt- cr6,.Lretzero fadd fp3,fp2,fp10 /* |x|+=0.5 bias to prepare to round. */ - bge cr3,.Lconvert /* x is positive so don't negate x. */ + bge cr7,.Lconvert /* x is positive so don't negate x. */ fnabs fp3,fp3 /* -(|x|+=0.5) */ .Lconvert: fctiwz fp4,fp3 /* Convert to Integer word lround toward 0. */ Jakub