From: Siddhesh Poyarekar <siddhesh@sourceware.org>
To: libc-alpha@sourceware.org
Subject: [PATCH 1/4] consolidate sign checks for slow2
Date: Tue, 27 Sep 2016 17:49:00 -0000 [thread overview]
Message-ID: <1474998553-2366-2-git-send-email-siddhesh@sourceware.org> (raw)
In-Reply-To: <1474998553-2366-1-git-send-email-siddhesh@sourceware.org>
Simplify the code a bit by consolidating sign checks in slow1 and
slow2 into __sin at the higher level.
Siddhesh
* sysdeps/ieee754/dbl-64/s_sin.c (slow1): Consolidate sign
check from here...
(slow2): ... and here...
(__sin): ... to here.
---
sysdeps/ieee754/dbl-64/s_sin.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/sysdeps/ieee754/dbl-64/s_sin.c b/sysdeps/ieee754/dbl-64/s_sin.c
index 18f1789..d60feb4 100644
--- a/sysdeps/ieee754/dbl-64/s_sin.c
+++ b/sysdeps/ieee754/dbl-64/s_sin.c
@@ -478,7 +478,8 @@ __sin (double x)
else if (k < 0x3feb6000)
{
res = do_sin (x, 0, &cor);
- retval = (res == res + 1.096 * cor) ? (m > 0 ? res : -res) : slow1 (x);
+ retval = (res == res + 1.096 * cor) ? res : slow1 (x);
+ retval = m > 0 ? retval : -retval;
} /* else if (k < 0x3feb6000) */
/*----------------------- 0.855469 <|x|<2.426265 ----------------------*/
@@ -487,7 +488,8 @@ __sin (double x)
t = hp0 - fabs (x);
res = do_cos (t, hp1, &cor);
- retval = (res == res + 1.020 * cor) ? ((m > 0) ? res : -res) : slow2 (x);
+ retval = (res == res + 1.020 * cor) ? res : slow2 (x);
+ retval = m > 0 ? retval : -retval;
} /* else if (k < 0x400368fd) */
#ifndef IN_SINCOS
@@ -650,13 +652,13 @@ slow1 (double x)
res = do_sin_slow (x, 0, 0, &cor);
if (res == res + cor)
- return (x > 0) ? res : -res;
+ return res;
__dubsin (fabs (x), 0, w);
if (w[0] == w[0] + 1.000000005 * w[1])
- return (x > 0) ? w[0] : -w[0];
+ return w[0];
- return (x > 0) ? __mpsin (x, 0, false) : -__mpsin (-x, 0, false);
+ return __mpsin (fabs (x), 0, false);
}
/**************************************************************************/
@@ -672,16 +674,16 @@ slow2 (double x)
double t = hp0 - fabs (x);
res = do_cos_slow (t, hp1, 0, &cor);
if (res == res + cor)
- return (x > 0) ? res : -res;
+ return res;
y = fabs (x) - hp0;
y1 = y - hp1;
y2 = (y - y1) - hp1;
__docos (y1, y2, w);
if (w[0] == w[0] + 1.000000005 * w[1])
- return (x > 0) ? w[0] : -w[0];
+ return w[0];
- return (x > 0) ? __mpsin (x, 0, false) : -__mpsin (-x, 0, false);
+ return __mpsin (fabs (x), 0, false);
}
/***************************************************************************/
--
2.7.4
next prev parent reply other threads:[~2016-09-27 17:49 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-27 17:49 [PATCH 0/4] Use __copysign in sincos wherever possible Siddhesh Poyarekar
2016-09-27 17:49 ` [PATCH 2/4] Check n instead of k1 to decide on sign of sin/cos result Siddhesh Poyarekar
2016-09-28 19:55 ` Carlos O'Donell
2016-09-28 21:58 ` Siddhesh Poyarekar
2016-09-30 0:37 ` Carlos O'Donell
2016-10-05 19:08 ` Siddhesh Poyarekar
2016-09-27 17:49 ` [PATCH 3/4] Use copysign instead of ternary conditions for positive constants Siddhesh Poyarekar
2016-09-28 19:58 ` Carlos O'Donell
2016-09-27 17:49 ` [PATCH 4/4] Use copysign instead of ternary for some sin/cos input ranges Siddhesh Poyarekar
2016-09-28 12:59 ` Manfred
2016-09-28 20:04 ` Carlos O'Donell
2016-09-28 21:32 ` Siddhesh Poyarekar
2016-09-28 20:09 ` Carlos O'Donell
2016-09-27 17:49 ` Siddhesh Poyarekar [this message]
2016-09-27 20:03 ` [PATCH 1/4] consolidate sign checks for slow2 Carlos O'Donell
2016-09-27 19:10 ` [PATCH 0/4] Use __copysign in sincos wherever possible Carlos O'Donell
2016-09-27 19:18 ` Siddhesh Poyarekar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1474998553-2366-2-git-send-email-siddhesh@sourceware.org \
--to=siddhesh@sourceware.org \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).