From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12912 invoked by alias); 15 Nov 2003 14:48:53 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 12858 invoked from network); 15 Nov 2003 14:48:52 -0000 Received: from unknown (HELO Cantor.suse.de) (195.135.220.2) by sources.redhat.com with SMTP; 15 Nov 2003 14:48:52 -0000 Received: from Hermes.suse.de (Hermes.suse.de [195.135.221.8]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by Cantor.suse.de (Postfix) with ESMTP id 2BDAF17F7553 for ; Sat, 15 Nov 2003 15:48:52 +0100 (CET) Received: from aj by arthur.inka.de with local (Exim 4.12) id 1AL1jF-0002fO-00 for libc-hacker@sources.redhat.com; Sat, 15 Nov 2003 15:48:49 +0100 To: GNU libc hacker Subject: floor etc for AMD64 From: Andreas Jaeger Date: Sat, 15 Nov 2003 14:48:00 -0000 Message-ID: User-Agent: Gnus/5.1003 (Gnus v5.10.3) XEmacs/21.4 (Rational FORTRAN, linux) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-SW-Source: 2003-11/txt/msg00076.txt.bz2 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Content-length: 7554 floor was broken the same way that ceil was on AMD64. I've added a test to libm-test.inc that caught this and added some further long double functions for AMD64. Ok to commit? The testsuite on AMD64 passes all math tests. Andreas 2003-11-15 Andreas Jaeger * sysdeps/x86_64/fpu/s_scalbnl.S: New. * sysdeps/x86_64/fpu/s_truncl.S: New. * sysdeps/x86_64/fpu/s_nearbyintl.S: New. * sysdeps/x86_64/fpu/s_floorl.S: New. * sysdeps/x86_64/fpu/s_ilogbl.S: New. * sysdeps/x86_64/fpu/e_remainderl.S: New. * math/libm-test.inc (floor_test): Test also +/-0.25. (ceil_test): Test -0.25. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Index: math/libm-test.inc --- math/libm-test.inc 14 Nov 2003 00:34:54 -0000 1.52 +++ math/libm-test.inc 15 Nov 2003 14:47:52 -0000 @@ -1626,6 +1626,7 @@ ceil_test (void) TEST_f_f (ceil, M_PIl, 4.0); TEST_f_f (ceil, -M_PIl, -3.0); TEST_f_f (ceil, 0.25, 1.0); + TEST_f_f (ceil, -0.25, minus_zero); =20 END (ceil); } @@ -2571,6 +2572,9 @@ floor_test (void) =20 TEST_f_f (floor, M_PIl, 3.0); TEST_f_f (floor, -M_PIl, -4.0); + + TEST_f_f (floor, 0.25, 0.0); + TEST_f_f (floor, -0.25, -1.0); =20 END (floor); } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Index: sysdeps/x86_64/fpu/s_scalbnl.S --- sysdeps/x86_64/fpu/s_scalbnl.S created +++ sysdeps/x86_64/fpu/s_scalbnl.S 2003-11-15 15:12:53.000000000 +0100 1.1 @@ -0,0 +1,18 @@ +/* + * Written by J.T. Conklin . + * Changes for long double by Ulrich Drepper + * Changes for x86-64 by Andreas Jaeger =09 + * Public domain. + */ + +#include + +ENTRY(__scalbnl) + movl %edi,-4(%rsp) + fildl -4(%rsp) + fldt 8(%rsp) + fscale + fstp %st(1) + ret +END (__scalbnl) +weak_alias (__scalbnl, scalbnl) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Index: sysdeps/x86_64/fpu/s_truncl.S --- sysdeps/x86_64/fpu/s_truncl.S created +++ sysdeps/x86_64/fpu/s_truncl.S 2003-11-15 15:04:07.000000000 +0100 1.1 @@ -0,0 +1,34 @@ +/* Truncate long double value. + Copyright (C) 1997, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + +ENTRY(__truncl) + fldt 8(%rsp) + fstcw -4(%rsp) + movl $0xc00, %edx + orl -4(%rsp), %edx + movl %edx, -8(%rsp) + fldcw -8(%rsp) + frndint + fldcw -4(%rsp) + ret +END(__truncl) +weak_alias (__truncl, truncl) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Index: sysdeps/x86_64/fpu/s_nearbyintl.S --- sysdeps/x86_64/fpu/s_nearbyintl.S created +++ sysdeps/x86_64/fpu/s_nearbyintl.S 2003-11-15 14:59:18.000000000 +0100 1= .1 @@ -0,0 +1,21 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ +/* Adapted for use as nearbyint by Ulrich Drepper . */ + +#include + +ENTRY(__nearbyintl) + fldt 8(%rsp) + fnstcw -4(%rsp) + movl -4(%rsp), %eax + orl $0x20, %eax + movl %eax, -8(%rsp) + fldcw -8(%rsp) + frndint + fclex + fldcw -4(%rsp) + ret +END (__nearbyintl) +weak_alias (__nearbyintl, nearbyintl) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Index: sysdeps/x86_64/fpu/s_floorl.S --- sysdeps/x86_64/fpu/s_floorl.S created +++ sysdeps/x86_64/fpu/s_floorl.S 2003-11-15 14:53:36.000000000 +0100 1.1 @@ -0,0 +1,30 @@ +/* + * Written by J.T. Conklin . + * Changes for long double by Ulrich Drepper + * Changes for x86-64 by Andreas Jaeger =09 + * Public domain. + */ + +#include + +ENTRY(__floorl) + fldt 8(%rsp) + + fstcw -4(%rsp) /* store fpu control word */ + + /* We use here %edx although only the low 1 bits are defined. + But none of the operations should care and they are faster + than the 16 bit operations. */ + movl $0x400,%edx /* round towards -oo */ + orl -4(%rsp),%edx + andl $0xf7ff,%edx + movl %edx,-8(%rsp) + fldcw -8(%rsp) /* load modified control word */ + + frndint /* round */ + + fldcw -4(%rsp) /* restore original control word */ + + ret +END (__floorl) +weak_alias (__floorl, floorl) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Index: sysdeps/x86_64/fpu/e_remainderl.S --- sysdeps/x86_64/fpu/e_remainderl.S created +++ sysdeps/x86_64/fpu/e_remainderl.S 2003-11-15 15:46:14.000000000 +0100 1= .1 @@ -0,0 +1,20 @@ +/* + * Written by J.T. Conklin . + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper . + * Adapted for x86-64 by Andreas Jaeger . + */ + +#include + +ENTRY(__ieee754_remainderl) + fldt 24(%rsp) + fldt 8(%rsp) +1: fprem1 + fstsw %ax + testl $0x400,%eax + jnz 1b + fstp %st(1) + ret +END (__ieee754_remainderl) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Index: sysdeps/x86_64/fpu/s_ilogbl.S --- sysdeps/x86_64/fpu/s_ilogbl.S created +++ sysdeps/x86_64/fpu/s_ilogbl.S 2003-11-15 15:34:39.000000000 +0100 1.1 @@ -0,0 +1,35 @@ +/* + * Written by J.T. Conklin . + * Changes for long double by Ulrich Drepper + * Adapted for x86-64 by Andreas Jaeger . + * Public domain. + */ + +#include + +ENTRY(__ilogbl) + fldt 8(%rsp) +/* I added the following ugly construct because ilogb(+-Inf) is + required to return INT_MAX in ISO C99. + -- jakub@redhat.com. */ + fxam /* Is NaN or +-Inf? */ + fstsw %ax + movb $0x45, %dh + andb %ah, %dh + cmpb $0x05, %dh + je 1f /* Is +-Inf, jump. */ + + fxtract + fstp %st + + fistpl -4(%rsp) + fwait + movl -4(%rsp),%eax + + ret + +1: fstp %st + movl $0x7fffffff, %eax + ret +END (__ilogbl) +weak_alias (__ilogbl, ilogbl) --=20 Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Deutschherrnstr. 15-19, 90429 N=FCrnberg, Germany GPG fingerprint =3D 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 --=-=-= Content-Type: application/pgp-signature Content-length: 197 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQA/tjzQOJpWPMJyoSYRAsxJAJ9TGB0jEfuO18GvNrrwZpFWQ6MkbgCeMAKK NEeOLnhGR9S6KBYUrM0zc80= =TPtz -----END PGP SIGNATURE----- --=-=-=--