This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch master updated. glibc-2.18-127-g7849ff9
- From: siddhesh at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 19 Sep 2013 11:25:26 -0000
- Subject: GNU C Library master sources branch master updated. glibc-2.18-127-g7849ff9
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via 7849ff938cf30d6a381ee864048bc0b3e8c96475 (commit)
via cfa3c8865ff8519f5110c5c261eb8cd7ded144aa (commit)
via b348e1e3a62c593fc3a6b26dbb8199b2aba3e056 (commit)
via 6cce25f814400769e77d1d8d1fea0c5882faf0d2 (commit)
via 5eea0404a81a1c6acd45458aede9be2e870d8e5e (commit)
from 8a85c1b3579bac73c37dbe1498dfc8ceb1ff568c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=7849ff938cf30d6a381ee864048bc0b3e8c96475
commit 7849ff938cf30d6a381ee864048bc0b3e8c96475
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date: Thu Sep 19 16:55:27 2013 +0530
Add benchmark inputs for sincos
diff --git a/ChangeLog b/ChangeLog
index 37a6058..f2cf337 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2013-09-19 Siddhesh Poyarekar <siddhesh@redhat.com>
+ * benchtests/Makefile (bench): Add sincos.
+ * benchtests/bench-sincos.c: New file.
+
* math/libm-test.inc (cos_test_data): New test inputs.
(sin_test_data): Likewise.
diff --git a/benchtests/Makefile b/benchtests/Makefile
index 9cb4ff9..4f4bd54 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -21,7 +21,7 @@
subdir := benchtests
bench := acos acosh asin asinh atan atanh cos cosh exp log modf pow rint sin \
- sinh tan tanh
+ sincos sinh tan tanh
# String function benchmarks.
string-bench := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
@@ -98,6 +98,8 @@ tanh-ARGLIST = double
tanh-RET = double
LDLIBS-bench-tanh = -lm
+LDLIBS-bench-sincos = -lm
+
# Rules to build and execute the benchmarks. Do not put any benchmark
diff --git a/benchtests/bench-sincos.c b/benchtests/bench-sincos.c
new file mode 100644
index 0000000..7662dde
--- /dev/null
+++ b/benchtests/bench-sincos.c
@@ -0,0 +1,86 @@
+/* Copyright (C) 2013 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
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+extern void sincos (double, double *, double *);
+
+#define CALL_BENCH_FUNC(v, i, j, k) sincos ( variants[v].in[i].arg0, &j, &k);
+
+struct args
+{
+ volatile double arg0;
+};
+
+struct args in0[12] =
+{
+ { 0.9 },
+ { 2.3 },
+ { 3.7 },
+ { 3.9 },
+ { 4.0 },
+ { 4.7 },
+ { 5.9 },
+
+ { 0x1.000000cf4a2a1p0 },
+ { 0x1.0000010b239a8p0 },
+ { 0x1.00000162a932ap0 },
+ { 0x1.000002d452a11p0 },
+ { 0x1.000005bc7d86cp0 }
+};
+
+struct args in1[12] =
+{
+ { 0.93340582292648832662962377071381 },
+ { 2.3328432680770916363144351635128 },
+ { 3.7439477503636453548097051680088 },
+ { 3.9225160069792437411706487182528 },
+ { 4.0711651639931289992091478779912 },
+ { 4.7858438478542097982426639646292 },
+ { 5.9840767662578002727968851104379 },
+
+ { 0x1.000000cf4a2a2p0 },
+ { 0x1.0000010b239a9p0 },
+ { 0x1.00000162a932bp0 },
+ { 0x1.000002d452a10p0 },
+ { 0x1.000005bc7d86dp0 }
+};
+
+struct _variants
+{
+ const char *name;
+ int count;
+ struct args *in;
+};
+
+struct _variants variants[2] =
+ {
+ {"sincos()", 12, in0},
+ {"sincos(768bits)", 12, in1},
+ };
+
+#define NUM_VARIANTS 2
+#define NUM_SAMPLES(i) (variants[i].count)
+#define VARIANT(i) (variants[i].name)
+
+#define BENCH_FUNC(v, j) \
+({ \
+ volatile double iptr; \
+ volatile double iptr2; \
+ CALL_BENCH_FUNC (v, j, iptr, iptr2); \
+})
+
+#define FUNCNAME "sincos"
+#include "bench-skeleton.c"
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=cfa3c8865ff8519f5110c5c261eb8cd7ded144aa
commit cfa3c8865ff8519f5110c5c261eb8cd7ded144aa
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date: Thu Sep 19 16:54:23 2013 +0530
New test cases for sin and cos for multiple precision fallback
diff --git a/ChangeLog b/ChangeLog
index e664599..37a6058 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2013-09-19 Siddhesh Poyarekar <siddhesh@redhat.com>
+ * math/libm-test.inc (cos_test_data): New test inputs.
+ (sin_test_data): Likewise.
+
* sysdeps/ieee754/dbl-64/s_sin.c (SINCOS_TABLE_LOOKUP): New
macro.
(__sin): Use it.
diff --git a/math/libm-test.inc b/math/libm-test.inc
index fe85bb9..2cb3d2c 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -6836,6 +6836,14 @@ static const struct test_f_f_data cos_test_data[] =
TEST_f_f (cos, 0x1.fffffep+127, 8.53021039830304158051791467692161107353094e-01L),
TEST_f_f (cos, 0x1p+50, 8.68095904660550604334592502063501320395739e-01L),
TEST_f_f (cos, 0x1p+28, -1.65568979490578758865468278195361551113358e-01L),
+
+#ifdef TEST_DOUBLE
+ TEST_f_f (cos, 0x1.000000cf4a2a2p0, 0x1.14a27f9e7521ep-1);
+ TEST_f_f (cos, 0x1.0000010b239a9p0, 0x1.14a27f39bc09dp-1);
+ TEST_f_f (cos, 0x1.00000162a932bp0, 0x1.14a27ea670b8cp-1);
+ TEST_f_f (cos, 0x1.000002d452a10p0, 0x1.14a27c385222ep-1);
+ TEST_f_f (cos, 0x1.000005bc7d86dp0, 0x1.14a27753ee07ap-1);
+#endif
};
static void
@@ -13305,6 +13313,16 @@ static const struct test_f_f_data sin_test_data[] =
TEST_f_f (sin, 0x1.fffffep+127, -5.21876523333658540551505357019806722935726e-01L),
TEST_f_f (sin, 0x1p+50, 4.96396515208940840876821859865411368093356e-01L),
TEST_f_f (sin, 0x1p+28, -9.86198211836975655703110310527108292055548e-01L),
+
+#ifdef TEST_DOUBLE
+ TEST_f_f (sin, 0.93340582292648832662962377071381, 0x1.9b78326675a75p-1);
+ TEST_f_f (sin, 2.3328432680770916363144351635128, 0x1.7264abddb4205p-1);
+ TEST_f_f (sin, 3.7439477503636453548097051680088, -0x1.2217622485d94p-1);
+ TEST_f_f (sin, 3.9225160069792437411706487182528, -0x1.686a3d55a1306p-1);
+ TEST_f_f (sin, 4.0711651639931289992091478779912, -0x1.9a4c6be7f5eadp-1);
+ TEST_f_f (sin, 4.7858438478542097982426639646292, -0x1.fe9e8d4105e51p-1);
+ TEST_f_f (sin, 5.9840767662578002727968851104379, -0x1.2dbd90aa4d692p-2);
+#endif
};
static void
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=b348e1e3a62c593fc3a6b26dbb8199b2aba3e056
commit b348e1e3a62c593fc3a6b26dbb8199b2aba3e056
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date: Thu Sep 19 16:51:01 2013 +0530
Consolidate sin/cos table lookup code
diff --git a/ChangeLog b/ChangeLog
index 3245378..e664599 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
2013-09-19 Siddhesh Poyarekar <siddhesh@redhat.com>
+ * sysdeps/ieee754/dbl-64/s_sin.c (SINCOS_TABLE_LOOKUP): New
+ macro.
+ (__sin): Use it.
+ (__cos): Likewise.
+ (slow1): Likewise.
+ (slow2): Likewise.
+ (sloww1): Likewise.
+ (sloww2): Likewise.
+ (bsloww1): Likewise.
+ (bsloww2): Likewise.
+ (cslow2): Likewise.
+ (csloww1): Likewise.
+ (csloww2): Likewise.
+
* sysdeps/ieee754/dbl-64/s_sin.c (reduce_and_compute): New
function.
(__sin): Use it.
diff --git a/sysdeps/ieee754/dbl-64/s_sin.c b/sysdeps/ieee754/dbl-64/s_sin.c
index 93ad8d7..6c1475b 100644
--- a/sysdeps/ieee754/dbl-64/s_sin.c
+++ b/sysdeps/ieee754/dbl-64/s_sin.c
@@ -55,6 +55,15 @@
#include <math_private.h>
#include <fenv.h>
+#define SINCOS_TABLE_LOOKUP(u, sn, ssn, cs, ccs) \
+({ \
+ int4 k = u.i[LOW_HALF] << 2; \
+ sn = __sincostab.x[k]; \
+ ssn = __sincostab.x[k + 1]; \
+ cs = __sincostab.x[k + 2]; \
+ ccs = __sincostab.x[k + 3]; \
+})
+
#ifndef SECTION
# define SECTION
#endif
@@ -166,11 +175,12 @@ __sin (double x)
xx = y * y;
s = y + y * xx * (sn3 + xx * sn5);
c = xx * (cs2 + xx * (cs4 + xx * cs6));
- k = u.i[LOW_HALF] << 2;
- sn = (m > 0) ? __sincostab.x[k] : -__sincostab.x[k];
- ssn = (m > 0) ? __sincostab.x[k + 1] : -__sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
+ if (m <= 0)
+ {
+ sn = -sn;
+ ssn = -ssn;
+ }
cor = (ssn + s * ccs - sn * c) + cs * s;
res = sn + cor;
cor = (sn - res) + cor;
@@ -195,11 +205,7 @@ __sin (double x)
xx = y * y;
s = y + y * xx * (sn3 + xx * sn5);
c = xx * (cs2 + xx * (cs4 + xx * cs6));
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
cor = (ccs - s * ssn - cs * c) - sn * s;
res = cs + cor;
cor = (cs - res) + cor;
@@ -258,11 +264,7 @@ __sin (double x)
xx = y * y;
s = y + (db + y * xx * (sn3 + xx * sn5));
c = y * db + xx * (cs2 + xx * (cs4 + xx * cs6));
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
cor = (ssn + s * ccs - sn * c) + cs * s;
res = sn + cor;
cor = (sn - res) + cor;
@@ -282,11 +284,7 @@ __sin (double x)
u.x = big.x + a;
y = a - (u.x - big.x) + da;
xx = y * y;
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
s = y + y * xx * (sn3 + xx * sn5);
c = xx * (cs2 + xx * (cs4 + xx * cs6));
cor = (ccs - s * ssn - cs * c) - sn * s;
@@ -356,11 +354,7 @@ __sin (double x)
xx = y * y;
s = y + (db + y * xx * (sn3 + xx * sn5));
c = y * db + xx * (cs2 + xx * (cs4 + xx * cs6));
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
cor = (ssn + s * ccs - sn * c) + cs * s;
res = sn + cor;
cor = (sn - res) + cor;
@@ -380,11 +374,7 @@ __sin (double x)
u.x = big.x + a;
y = a - (u.x - big.x) + da;
xx = y * y;
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
s = y + y * xx * (sn3 + xx * sn5);
c = xx * (cs2 + xx * (cs4 + xx * cs6));
cor = (ccs - s * ssn - cs * c) - sn * s;
@@ -447,11 +437,7 @@ __cos (double x)
xx = y * y;
s = y + y * xx * (sn3 + xx * sn5);
c = xx * (cs2 + xx * (cs4 + xx * cs6));
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
cor = (ccs - s * ssn - cs * c) - sn * s;
res = cs + cor;
cor = (cs - res) + cor;
@@ -492,11 +478,7 @@ __cos (double x)
xx = y * y;
s = y + (db + y * xx * (sn3 + xx * sn5));
c = y * db + xx * (cs2 + xx * (cs4 + xx * cs6));
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
cor = (ssn + s * ccs - sn * c) + cs * s;
res = sn + cor;
cor = (sn - res) + cor;
@@ -558,11 +540,7 @@ __cos (double x)
xx = y * y;
s = y + (db + y * xx * (sn3 + xx * sn5));
c = y * db + xx * (cs2 + xx * (cs4 + xx * cs6));
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
cor = (ssn + s * ccs - sn * c) + cs * s;
res = sn + cor;
cor = (sn - res) + cor;
@@ -582,11 +560,7 @@ __cos (double x)
u.x = big.x + a;
y = a - (u.x - big.x) + da;
xx = y * y;
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
s = y + y * xx * (sn3 + xx * sn5);
c = xx * (cs2 + xx * (cs4 + xx * cs6));
cor = (ccs - s * ssn - cs * c) - sn * s;
@@ -654,11 +628,7 @@ __cos (double x)
xx = y * y;
s = y + (db + y * xx * (sn3 + xx * sn5));
c = y * db + xx * (cs2 + xx * (cs4 + xx * cs6));
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
cor = (ssn + s * ccs - sn * c) + cs * s;
res = sn + cor;
cor = (sn - res) + cor;
@@ -678,11 +648,7 @@ __cos (double x)
u.x = big.x + a;
y = a - (u.x - big.x) + da;
xx = y * y;
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
s = y + y * xx * (sn3 + xx * sn5);
c = xx * (cs2 + xx * (cs4 + xx * cs6));
cor = (ccs - s * ssn - cs * c) - sn * s;
@@ -754,18 +720,13 @@ slow1 (double x)
mynumber u;
double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, c1, c2, xx, cor, res;
static const double t22 = 6291456.0;
- int4 k;
y = ABS (x);
u.x = big.x + y;
y = y - (u.x - big.x);
xx = y * y;
s = y * xx * (sn3 + xx * sn5);
c = xx * (cs2 + xx * (cs4 + xx * cs6));
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k]; /* Data */
- ssn = __sincostab.x[k + 1]; /* from */
- cs = __sincostab.x[k + 2]; /* tables */
- ccs = __sincostab.x[k + 3]; /* __sincostab.tbl */
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
y1 = (y + t22) - t22;
y2 = y - y1;
c1 = (cs + t22) - t22;
@@ -798,7 +759,6 @@ slow2 (double x)
mynumber u;
double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, e1, e2, xx, cor, res, del;
static const double t22 = 6291456.0;
- int4 k;
y = ABS (x);
y = hp0.x - y;
if (y >= 0)
@@ -816,11 +776,7 @@ slow2 (double x)
xx = y * y;
s = y * xx * (sn3 + xx * sn5);
c = y * del + xx * (cs2 + xx * (cs4 + xx * cs6));
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
y1 = (y + t22) - t22;
y2 = (y - y1) + del;
e1 = (sn + t22) - t22;
@@ -937,7 +893,6 @@ sloww1 (double x, double dx, double orig)
mynumber u;
double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, c1, c2, xx, cor, res;
static const double t22 = 6291456.0;
- int4 k;
y = ABS (x);
u.x = big.x + y;
@@ -946,11 +901,7 @@ sloww1 (double x, double dx, double orig)
xx = y * y;
s = y * xx * (sn3 + xx * sn5);
c = xx * (cs2 + xx * (cs4 + xx * cs6));
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
y1 = (y + t22) - t22;
y2 = (y - y1) + dx;
c1 = (cs + t22) - t22;
@@ -998,7 +949,6 @@ sloww2 (double x, double dx, double orig, int n)
mynumber u;
double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, e1, e2, xx, cor, res;
static const double t22 = 6291456.0;
- int4 k;
y = ABS (x);
u.x = big.x + y;
@@ -1007,11 +957,7 @@ sloww2 (double x, double dx, double orig, int n)
xx = y * y;
s = y * xx * (sn3 + xx * sn5);
c = y * dx + xx * (cs2 + xx * (cs4 + xx * cs6));
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
y1 = (y + t22) - t22;
y2 = (y - y1) + dx;
@@ -1102,7 +1048,6 @@ bsloww1 (double x, double dx, double orig, int n)
mynumber u;
double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, c1, c2, xx, cor, res;
static const double t22 = 6291456.0;
- int4 k;
y = ABS (x);
u.x = big.x + y;
@@ -1111,11 +1056,7 @@ bsloww1 (double x, double dx, double orig, int n)
xx = y * y;
s = y * xx * (sn3 + xx * sn5);
c = xx * (cs2 + xx * (cs4 + xx * cs6));
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
y1 = (y + t22) - t22;
y2 = (y - y1) + dx;
c1 = (cs + t22) - t22;
@@ -1158,7 +1099,6 @@ bsloww2 (double x, double dx, double orig, int n)
mynumber u;
double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, e1, e2, xx, cor, res;
static const double t22 = 6291456.0;
- int4 k;
y = ABS (x);
u.x = big.x + y;
@@ -1167,11 +1107,7 @@ bsloww2 (double x, double dx, double orig, int n)
xx = y * y;
s = y * xx * (sn3 + xx * sn5);
c = y * dx + xx * (cs2 + xx * (cs4 + xx * cs6));
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
y1 = (y + t22) - t22;
y2 = (y - y1) + dx;
@@ -1213,7 +1149,6 @@ cslow2 (double x)
mynumber u;
double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, e1, e2, xx, cor, res;
static const double t22 = 6291456.0;
- int4 k;
y = ABS (x);
u.x = big.x + y;
@@ -1221,11 +1156,7 @@ cslow2 (double x)
xx = y * y;
s = y * xx * (sn3 + xx * sn5);
c = xx * (cs2 + xx * (cs4 + xx * cs6));
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
y1 = (y + t22) - t22;
y2 = y - y1;
e1 = (sn + t22) - t22;
@@ -1346,7 +1277,6 @@ csloww1 (double x, double dx, double orig)
mynumber u;
double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, c1, c2, xx, cor, res;
static const double t22 = 6291456.0;
- int4 k;
y = ABS (x);
u.x = big.x + y;
@@ -1355,11 +1285,7 @@ csloww1 (double x, double dx, double orig)
xx = y * y;
s = y * xx * (sn3 + xx * sn5);
c = xx * (cs2 + xx * (cs4 + xx * cs6));
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
y1 = (y + t22) - t22;
y2 = (y - y1) + dx;
c1 = (cs + t22) - t22;
@@ -1406,7 +1332,6 @@ csloww2 (double x, double dx, double orig, int n)
mynumber u;
double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, e1, e2, xx, cor, res;
static const double t22 = 6291456.0;
- int4 k;
y = ABS (x);
u.x = big.x + y;
@@ -1415,11 +1340,7 @@ csloww2 (double x, double dx, double orig, int n)
xx = y * y;
s = y * xx * (sn3 + xx * sn5);
c = y * dx + xx * (cs2 + xx * (cs4 + xx * cs6));
- k = u.i[LOW_HALF] << 2;
- sn = __sincostab.x[k];
- ssn = __sincostab.x[k + 1];
- cs = __sincostab.x[k + 2];
- ccs = __sincostab.x[k + 3];
+ SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs);
y1 = (y + t22) - t22;
y2 = (y - y1) + dx;
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=6cce25f814400769e77d1d8d1fea0c5882faf0d2
commit 6cce25f814400769e77d1d8d1fea0c5882faf0d2
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date: Thu Sep 19 16:45:27 2013 +0530
Consolidate sin/cos computation for large inputs
diff --git a/ChangeLog b/ChangeLog
index 0591a96..3245378 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2013-09-19 Siddhesh Poyarekar <siddhesh@redhat.com>
+ * sysdeps/ieee754/dbl-64/s_sin.c (reduce_and_compute): New
+ function.
+ (__sin): Use it.
+ (__cos): Likewise.
+
* sysdeps/ieee754/dbl-64/s_sin.c (__sin): Remove redundant
gotos.
(__cos): Likewise.
diff --git a/sysdeps/ieee754/dbl-64/s_sin.c b/sysdeps/ieee754/dbl-64/s_sin.c
index 473c0f3..93ad8d7 100644
--- a/sysdeps/ieee754/dbl-64/s_sin.c
+++ b/sysdeps/ieee754/dbl-64/s_sin.c
@@ -93,6 +93,39 @@ static double csloww (double x, double dx, double orig);
static double csloww1 (double x, double dx, double orig);
static double csloww2 (double x, double dx, double orig, int n);
+/* Reduce range of X and compute sin of a + da. K is the amount by which to
+ rotate the quadrants. This allows us to use the same routine to compute cos
+ by simply rotating the quadrants by 1. */
+static inline double
+__always_inline
+reduce_and_compute (double x, double a, double da, unsigned int k)
+{
+ double retval = 0;
+ unsigned int n = __branred (x, &a, &da);
+ k = (n + k) % 4;
+ switch (k)
+ {
+ case 0:
+ if (a * a < 0.01588)
+ retval = bsloww (a, da, x, n);
+ else
+ retval = bsloww1 (a, da, x, n);
+ break;
+ case 2:
+ if (a * a < 0.01588)
+ retval = bsloww (-a, -da, x, n);
+ else
+ retval = bsloww1 (-a, -da, x, n);
+ break;
+
+ case 1:
+ case 3:
+ retval = bsloww2 (a, da, x, n);
+ break;
+ }
+ return retval;
+}
+
/*******************************************************************/
/* An ultimate sin routine. Given an IEEE double machine number x */
/* it computes the correctly rounded (to nearest) value of sin(x) */
@@ -366,29 +399,7 @@ __sin (double x)
/* -----------------281474976710656 <|x| <2^1024----------------------------*/
else if (k < 0x7ff00000)
- {
- n = __branred (x, &a, &da);
- switch (n)
- {
- case 0:
- if (a * a < 0.01588)
- retval = bsloww (a, da, x, n);
- else
- retval = bsloww1 (a, da, x, n);
- break;
- case 2:
- if (a * a < 0.01588)
- retval = bsloww (-a, -da, x, n);
- else
- retval = bsloww1 (-a, -da, x, n);
- break;
-
- case 1:
- case 3:
- retval = bsloww2 (a, da, x, n);
- break;
- }
- } /* else if (k < 0x7ff00000 ) */
+ retval = reduce_and_compute (x, a, da, 0);
/*--------------------- |x| > 2^1024 ----------------------------------*/
else
@@ -684,31 +695,9 @@ __cos (double x)
}
} /* else if (k < 0x42F00000 ) */
+ /* 281474976710656 <|x| <2^1024 */
else if (k < 0x7ff00000)
- { /* 281474976710656 <|x| <2^1024 */
-
- n = __branred (x, &a, &da);
- switch (n)
- {
- case 1:
- if (a * a < 0.01588)
- retval = bsloww (-a, -da, x, n);
- else
- retval = bsloww1 (-a, -da, x, n);
- break;
- case 3:
- if (a * a < 0.01588)
- retval = bsloww (a, da, x, n);
- else
- retval = bsloww1 (a, da, x, n);
- break;
-
- case 0:
- case 2:
- retval = bsloww2 (a, da, x, n);
- break;
- }
- } /* else if (k < 0x7ff00000 ) */
+ retval = reduce_and_compute (x, a, da, 1);
else
{
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=5eea0404a81a1c6acd45458aede9be2e870d8e5e
commit 5eea0404a81a1c6acd45458aede9be2e870d8e5e
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date: Thu Sep 19 16:43:53 2013 +0530
Remove redundant goto lines
diff --git a/ChangeLog b/ChangeLog
index ded0487..0591a96 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-09-19 Siddhesh Poyarekar <siddhesh@redhat.com>
+
+ * sysdeps/ieee754/dbl-64/s_sin.c (__sin): Remove redundant
+ gotos.
+ (__cos): Likewise.
+
2013-09-18 Maciej W. Rozycki <macro@codesourcery.com>
* config.h.in (HAVE_MIPS_NAN2008): New macro.
diff --git a/sysdeps/ieee754/dbl-64/s_sin.c b/sysdeps/ieee754/dbl-64/s_sin.c
index 5c388c8..473c0f3 100644
--- a/sysdeps/ieee754/dbl-64/s_sin.c
+++ b/sysdeps/ieee754/dbl-64/s_sin.c
@@ -113,10 +113,7 @@ __sin (double x)
m = u.i[HIGH_HALF];
k = 0x7fffffff & m; /* no sign */
if (k < 0x3e500000) /* if x->0 =>sin(x)=x */
- {
- retval = x;
- goto ret;
- }
+ retval = x;
/*---------------------------- 2^-26 < |x|< 0.25 ----------------------*/
else if (k < 0x3fd00000)
{
@@ -127,7 +124,6 @@ __sin (double x)
res = x + t;
cor = (x - res) + t;
retval = (res == res + 1.07 * cor) ? res : slow (x);
- goto ret;
} /* else if (k < 0x3fd00000) */
/*---------------------------- 0.25<|x|< 0.855469---------------------- */
else if (k < 0x3feb6000)
@@ -146,7 +142,6 @@ __sin (double x)
res = sn + cor;
cor = (sn - res) + cor;
retval = (res == res + 1.096 * cor) ? res : slow1 (x);
- goto ret;
} /* else if (k < 0x3feb6000) */
/*----------------------- 0.855469 <|x|<2.426265 ----------------------*/
@@ -176,7 +171,6 @@ __sin (double x)
res = cs + cor;
cor = (cs - res) + cor;
retval = (res == res + 1.020 * cor) ? ((m > 0) ? res : -res) : slow2 (x);
- goto ret;
} /* else if (k < 0x400368fd) */
/*-------------------------- 2.426265<|x|< 105414350 ----------------------*/
@@ -211,7 +205,6 @@ __sin (double x)
cor = (a - res) + t;
cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
retval = (res == res + cor) ? res : sloww (a, da, x);
- goto ret;
}
else
{
@@ -243,7 +236,6 @@ __sin (double x)
cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
retval = ((res == res + cor) ? ((m) ? res : -res)
: sloww1 (a, da, x));
- goto ret;
}
break;
@@ -270,11 +262,8 @@ __sin (double x)
cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
retval = ((res == res + cor) ? ((n & 2) ? -res : res)
: sloww2 (a, da, x, n));
- goto ret;
-
break;
}
-
} /* else if (k < 0x419921FB ) */
/*---------------------105414350 <|x|< 281474976710656 --------------------*/
@@ -314,7 +303,6 @@ __sin (double x)
cor = (a - res) + t;
cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
retval = (res == res + cor) ? res : bsloww (a, da, x, n);
- goto ret;
}
else
{
@@ -346,7 +334,6 @@ __sin (double x)
cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
retval = ((res == res + cor) ? ((m) ? res : -res)
: bsloww1 (a, da, x, n));
- goto ret;
}
break;
@@ -373,8 +360,6 @@ __sin (double x)
cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
retval = ((res == res + cor) ? ((n & 2) ? -res : res)
: bsloww2 (a, da, x, n));
- goto ret;
-
break;
}
} /* else if (k < 0x42F00000 ) */
@@ -390,20 +375,17 @@ __sin (double x)
retval = bsloww (a, da, x, n);
else
retval = bsloww1 (a, da, x, n);
- goto ret;
break;
case 2:
if (a * a < 0.01588)
retval = bsloww (-a, -da, x, n);
else
retval = bsloww1 (-a, -da, x, n);
- goto ret;
break;
case 1:
case 3:
retval = bsloww2 (a, da, x, n);
- goto ret;
break;
}
} /* else if (k < 0x7ff00000 ) */
@@ -414,10 +396,8 @@ __sin (double x)
if (k == 0x7ff00000 && u.i[LOW_HALF] == 0)
__set_errno (EDOM);
retval = x / x;
- goto ret;
}
-ret:
return retval;
}
@@ -444,11 +424,9 @@ __cos (double x)
m = u.i[HIGH_HALF];
k = 0x7fffffff & m;
+ /* |x|<2^-27 => cos(x)=1 */
if (k < 0x3e400000)
- {
- retval = 1.0;
- goto ret;
- } /* |x|<2^-27 => cos(x)=1 */
+ retval = 1.0;
else if (k < 0x3feb6000)
{ /* 2^-27 < |x| < 0.855469 */
@@ -467,7 +445,6 @@ __cos (double x)
res = cs + cor;
cor = (cs - res) + cor;
retval = (res == res + 1.020 * cor) ? res : cslow2 (x);
- goto ret;
} /* else if (k < 0x3feb6000) */
else if (k < 0x400368fd)
@@ -484,7 +461,6 @@ __cos (double x)
cor = (a - res) + t;
cor = (cor > 0) ? 1.02 * cor + 1.0e-31 : 1.02 * cor - 1.0e-31;
retval = (res == res + cor) ? res : csloww (a, da, x);
- goto ret;
}
else
{
@@ -516,7 +492,6 @@ __cos (double x)
cor = (cor > 0) ? 1.035 * cor + 1.0e-31 : 1.035 * cor - 1.0e-31;
retval = ((res == res + cor) ? ((m) ? res : -res)
: csloww1 (a, da, x));
- goto ret;
}
} /* else if (k < 0x400368fd) */
@@ -552,7 +527,6 @@ __cos (double x)
cor = (a - res) + t;
cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
retval = (res == res + cor) ? res : csloww (a, da, x);
- goto ret;
}
else
{
@@ -584,7 +558,6 @@ __cos (double x)
cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
retval = ((res == res + cor) ? ((m) ? res : -res)
: csloww1 (a, da, x));
- goto ret;
}
break;
@@ -611,8 +584,6 @@ __cos (double x)
cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
retval = ((res == res + cor) ? ((n) ? -res : res)
: csloww2 (a, da, x, n));
- goto ret;
-
break;
}
} /* else if (k < 0x419921FB ) */
@@ -652,7 +623,6 @@ __cos (double x)
cor = (a - res) + t;
cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
retval = (res == res + cor) ? res : bsloww (a, da, x, n);
- goto ret;
}
else
{
@@ -684,7 +654,6 @@ __cos (double x)
cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
retval = ((res == res + cor) ? ((m) ? res : -res)
: bsloww1 (a, da, x, n));
- goto ret;
}
break;
@@ -711,7 +680,6 @@ __cos (double x)
cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
retval = ((res == res + cor) ? ((n) ? -res : res)
: bsloww2 (a, da, x, n));
- goto ret;
break;
}
} /* else if (k < 0x42F00000 ) */
@@ -727,20 +695,17 @@ __cos (double x)
retval = bsloww (-a, -da, x, n);
else
retval = bsloww1 (-a, -da, x, n);
- goto ret;
break;
case 3:
if (a * a < 0.01588)
retval = bsloww (a, da, x, n);
else
retval = bsloww1 (a, da, x, n);
- goto ret;
break;
case 0:
case 2:
retval = bsloww2 (a, da, x, n);
- goto ret;
break;
}
} /* else if (k < 0x7ff00000 ) */
@@ -750,10 +715,8 @@ __cos (double x)
if (k == 0x7ff00000 && u.i[LOW_HALF] == 0)
__set_errno (EDOM);
retval = x / x; /* |x| > 2^1024 */
- goto ret;
}
-ret:
return retval;
}
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 31 +++++
benchtests/Makefile | 4 +-
benchtests/bench-sincos.c | 86 +++++++++++++
math/libm-test.inc | 18 +++
sysdeps/ieee754/dbl-64/s_sin.c | 275 +++++++++++-----------------------------
5 files changed, 212 insertions(+), 202 deletions(-)
create mode 100644 benchtests/bench-sincos.c
hooks/post-receive
--
GNU C Library master sources