From b76eb5f076d362cdfbb95f0986285a8661e4082f Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Thu, 27 Dec 2012 20:43:24 +0530 Subject: [PATCH] Move mpone out to a global const Code cleanup. --- ChangeLog | 15 +++++++++++ sysdeps/ieee754/dbl-64/mpa.c | 4 +++ sysdeps/ieee754/dbl-64/mpa.h | 2 ++ sysdeps/ieee754/dbl-64/mpatan.c | 9 +++---- sysdeps/ieee754/dbl-64/mpatan2.c | 4 --- sysdeps/ieee754/dbl-64/mpexp.c | 4 --- sysdeps/ieee754/dbl-64/mplog.c | 12 ++------- sysdeps/ieee754/dbl-64/mplog.h | 44 --------------------------------- sysdeps/x86_64/fpu/multiarch/mpa-avx.c | 1 + sysdeps/x86_64/fpu/multiarch/mpa-fma4.c | 1 + 10 files changed, 28 insertions(+), 68 deletions(-) delete mode 100644 sysdeps/ieee754/dbl-64/mplog.h diff --git a/ChangeLog b/ChangeLog index 86350e3..7216ca6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2012-12-27 Siddhesh Poyarekar + + * sysdeps/ieee754/dbl-64/mpa.c [! NO__CONST]: New constant + MPONE. + * sysdeps/ieee754/dbl-64/mpa.h: Declare MPONE. + * sysdeps/ieee754/dbl-64/mpatan.c (__mpatan): Remove local + variable MPONE. + * sysdeps/ieee754/dbl-64/mpatan2.c (__mpatan2): Likewise. + * sysdeps/ieee754/dbl-64/mpexp.c (__mpexp): Likewise. + * sysdeps/ieee754/dbl-64/mplog.c (__mplog): Remove mplog.h + include directive. Remove local variable MPONE. + * sysdeps/ieee754/dbl-64/mplog.h: Remove. + * sysdeps/x86_64/fpu/multiarch/mpa-avx.c: Define NO__CONST. + * sysdeps/x86_64/fpu/multiarch/mpa-fma4.c: Likewise. + 2012-12-25 David S. Miller * version.h (RELEASE): Set to "development". diff --git a/sysdeps/ieee754/dbl-64/mpa.c b/sysdeps/ieee754/dbl-64/mpa.c index 7e0ee44..b5d25ed 100644 --- a/sysdeps/ieee754/dbl-64/mpa.c +++ b/sysdeps/ieee754/dbl-64/mpa.c @@ -51,6 +51,10 @@ # define SECTION #endif +#ifndef NO__CONST +const mp_no mpone = {1, {1.0, 1.0}}; +#endif + #ifndef NO___ACR /* mcr() compares the sizes of the mantissas of two multiple precision */ /* numbers. Mantissas are compared regardless of the signs of the */ diff --git a/sysdeps/ieee754/dbl-64/mpa.h b/sysdeps/ieee754/dbl-64/mpa.h index 26ae2ac..4fdecb6 100644 --- a/sysdeps/ieee754/dbl-64/mpa.h +++ b/sysdeps/ieee754/dbl-64/mpa.h @@ -54,6 +54,8 @@ typedef struct {/* This structure holds the details of a multi-precision */ typedef union { int i[2]; double d; } number; +extern const mp_no mpone; + #define X x->d #define Y y->d #define Z z->d diff --git a/sysdeps/ieee754/dbl-64/mpatan.c b/sysdeps/ieee754/dbl-64/mpatan.c index 80637e5..d897bbb 100644 --- a/sysdeps/ieee754/dbl-64/mpatan.c +++ b/sysdeps/ieee754/dbl-64/mpatan.c @@ -48,9 +48,6 @@ __mpatan(mp_no *x, mp_no *y, int p) { int i,m,n; double dx; mp_no - mpone = {0,{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, - 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, - 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}}, mptwo = {0,{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}}, @@ -60,7 +57,7 @@ __mpatan(mp_no *x, mp_no *y, int p) { mp_no mps,mpsm,mpt,mpt1,mpt2,mpt3; - /* Choose m and initiate mpone, mptwo & mptwoim1 */ + /* Choose m and initiate mptwo & mptwoim1 */ if (EX>0) m=7; else if (EX<0) m=0; else { @@ -68,8 +65,8 @@ __mpatan(mp_no *x, mp_no *y, int p) { for (m=6; m>0; m--) {if (dx>__atan_xm[m].d) break;} } - mpone.e = mptwo.e = mptwoim1.e = 1; - mpone.d[0] = mpone.d[1] = mptwo.d[0] = mptwoim1.d[0] = ONE; + mptwo.e = mptwoim1.e = 1; + mptwo.d[0] = mptwoim1.d[0] = ONE; mptwo.d[1] = TWO; /* Reduce x m times */ diff --git a/sysdeps/ieee754/dbl-64/mpatan2.c b/sysdeps/ieee754/dbl-64/mpatan2.c index e9c9745..42cb6a7 100644 --- a/sysdeps/ieee754/dbl-64/mpatan2.c +++ b/sysdeps/ieee754/dbl-64/mpatan2.c @@ -51,14 +51,10 @@ __mpatan2(mp_no *y, mp_no *x, mp_no *z, int p) { static const double ZERO = 0.0, ONE = 1.0; - mp_no mpone = {0,{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, - 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, - 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}}; mp_no mpt1,mpt2,mpt3; if (X[0] <= ZERO) { - mpone.e = 1; mpone.d[0] = mpone.d[1] = ONE; __dvd(x,y,&mpt1,p); __mul(&mpt1,&mpt1,&mpt2,p); if (mpt1.d[0] != ZERO) mpt1.d[0] = ONE; __add(&mpt2,&mpone,&mpt3,p); __mpsqrt(&mpt3,&mpt2,p); diff --git a/sysdeps/ieee754/dbl-64/mpexp.c b/sysdeps/ieee754/dbl-64/mpexp.c index 6b1fcf2..2762ba9 100644 --- a/sysdeps/ieee754/dbl-64/mpexp.c +++ b/sysdeps/ieee754/dbl-64/mpexp.c @@ -56,9 +56,6 @@ __mpexp(mp_no *x, mp_no *y, int p) { { 0, 0, 0, 0, 0, 0,23,28,33,38,42,47,52,57,62,66, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0,27, 0, 0,39,43,47,51,55,59,63}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,43,47,50,54}}; - mp_no mpone = {0,{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, - 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, - 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}}; mp_no mpk = {0,{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}}; @@ -84,7 +81,6 @@ __mpexp(mp_no *x, mp_no *y, int p) { __mul(x,&mpt1,&mps,p); /* Evaluate the polynomial. Put result in mpt2 */ - mpone.e=1; mpone.d[0]=ONE; mpone.d[1]=ONE; mpk.e = 1; mpk.d[0] = ONE; mpk.d[1]=__mpexp_nn[n].d; __dvd(&mps,&mpk,&mpt1,p); __add(&mpone,&mpt1,&mpak,p); diff --git a/sysdeps/ieee754/dbl-64/mplog.c b/sysdeps/ieee754/dbl-64/mplog.c index 8255e2a..c0606c6 100644 --- a/sysdeps/ieee754/dbl-64/mplog.c +++ b/sysdeps/ieee754/dbl-64/mplog.c @@ -40,21 +40,13 @@ void __mpexp(mp_no *, mp_no *, int); void __mplog(mp_no *x, mp_no *y, int p) { -#include "mplog.h" int i,m; -#if 0 - int j,k,m1,m2,n; - double a,b; -#endif static const int mp[33] = {0,0,0,0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3, 4,4,4,4,4,4,4,4,4,4,4,4,4,4}; - mp_no mpone = {0,{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, - 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, - 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}}; mp_no mpt1,mpt2; - /* Choose m and initiate mpone */ - m = mp[p]; mpone.e = 1; mpone.d[0]=mpone.d[1]=ONE; + /* Choose m */ + m = mp[p]; /* Perform m newton iterations to solve for y: exp(y)-x=0. */ /* The iterations formula is: y(n+1)=y(n)+(x*exp(-y(n))-1). */ diff --git a/sysdeps/ieee754/dbl-64/mplog.h b/sysdeps/ieee754/dbl-64/mplog.h deleted file mode 100644 index b967f52..0000000 --- a/sysdeps/ieee754/dbl-64/mplog.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * IBM Accurate Mathematical Library - * Written by International Business Machines Corp. - * Copyright (C) 2001 Free Software Foundation, Inc. - * - * This program 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. - * - * This program 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 this program; if not, see . - */ - -/******************************************************************/ -/* */ -/* MODULE_NAME:mplog.h */ -/* */ -/* common data and variables prototype and definition */ -/******************************************************************/ - -#ifndef MPLOG_H -#define MPLOG_H - -#ifdef BIG_ENDI - static const number -/**/ one = {{0x3ff00000, 0x00000000} }; /* 1 */ - -#else -#ifdef LITTLE_ENDI - static const number -/**/ one = {{0x00000000, 0x3ff00000} }; /* 1 */ - -#endif -#endif - -#define ONE one.d - -#endif diff --git a/sysdeps/x86_64/fpu/multiarch/mpa-avx.c b/sysdeps/x86_64/fpu/multiarch/mpa-avx.c index a92dbed..d3f4d7a 100644 --- a/sysdeps/x86_64/fpu/multiarch/mpa-avx.c +++ b/sysdeps/x86_64/fpu/multiarch/mpa-avx.c @@ -7,6 +7,7 @@ #define NO___CPY 1 #define NO___MP_DBL 1 #define NO___ACR 1 +#define NO__CONST 1 #define SECTION __attribute__ ((section (".text.avx"))) #include diff --git a/sysdeps/x86_64/fpu/multiarch/mpa-fma4.c b/sysdeps/x86_64/fpu/multiarch/mpa-fma4.c index f8ed8f3..6abb671 100644 --- a/sysdeps/x86_64/fpu/multiarch/mpa-fma4.c +++ b/sysdeps/x86_64/fpu/multiarch/mpa-fma4.c @@ -7,6 +7,7 @@ #define NO___CPY 1 #define NO___MP_DBL 1 #define NO___ACR 1 +#define NO__CONST 1 #define SECTION __attribute__ ((section (".text.fma4"))) #include -- 2.7.4