public inbox for newlib-cvs@sourceware.org help / color / mirror / Atom feed
From: Jeff Johnston <jjohnstn@sourceware.org> To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] Fix rounding issues with sqrt/sqrtf Date: Fri, 4 Jun 2021 18:43:11 +0000 (GMT) [thread overview] Message-ID: <20210604184311.7059038515F0@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a9165ea07ce3a99bbfd294ada9c0fd54db738bb9 commit a9165ea07ce3a99bbfd294ada9c0fd54db738bb9 Author: Jeff Johnston <jjohnstn@redhat.com> Date: Fri Jun 4 14:36:38 2021 -0400 Fix rounding issues with sqrt/sqrtf - compiler is sometimes optimizing out the rounding check in e_sqrt.c and ef_sqrt.c which uses two constants to create an inexact operation - there is a similar constant operation in s_tanh.c/sf_tanh.c - make the one and tiny constants volatile to stop this Diff: --- newlib/libm/math/e_sqrt.c | 4 ++-- newlib/libm/math/ef_sqrt.c | 4 ++-- newlib/libm/math/s_tanh.c | 4 ++-- newlib/libm/math/sf_tanh.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/newlib/libm/math/e_sqrt.c b/newlib/libm/math/e_sqrt.c index 78fc52417..85dbdd1e7 100644 --- a/newlib/libm/math/e_sqrt.c +++ b/newlib/libm/math/e_sqrt.c @@ -86,9 +86,9 @@ #ifndef _DOUBLE_IS_32BITS #ifdef __STDC__ -static const double one = 1.0, tiny=1.0e-300; +static const volatile double one = 1.0, tiny=1.0e-300; #else -static double one = 1.0, tiny=1.0e-300; +static double volatile one = 1.0, tiny=1.0e-300; #endif #ifdef __STDC__ diff --git a/newlib/libm/math/ef_sqrt.c b/newlib/libm/math/ef_sqrt.c index 80e7f360e..448e26e57 100644 --- a/newlib/libm/math/ef_sqrt.c +++ b/newlib/libm/math/ef_sqrt.c @@ -16,9 +16,9 @@ #include "fdlibm.h" #ifdef __STDC__ -static const float one = 1.0, tiny=1.0e-30; +static const volatile float one = 1.0, tiny=1.0e-30; #else -static float one = 1.0, tiny=1.0e-30; +static float volatile one = 1.0, tiny=1.0e-30; #endif #ifdef __STDC__ diff --git a/newlib/libm/math/s_tanh.c b/newlib/libm/math/s_tanh.c index f7864306e..66018d7d0 100644 --- a/newlib/libm/math/s_tanh.c +++ b/newlib/libm/math/s_tanh.c @@ -73,9 +73,9 @@ PORTABILITY #ifndef _DOUBLE_IS_32BITS #ifdef __STDC__ -static const double one=1.0, two=2.0, tiny = 1.0e-300; +static const volatile double one=1.0, two=2.0, tiny = 1.0e-300; #else -static double one=1.0, two=2.0, tiny = 1.0e-300; +static double volatile one=1.0, two=2.0, tiny = 1.0e-300; #endif #ifdef __STDC__ diff --git a/newlib/libm/math/sf_tanh.c b/newlib/libm/math/sf_tanh.c index 1eb44a2ff..214bdb495 100644 --- a/newlib/libm/math/sf_tanh.c +++ b/newlib/libm/math/sf_tanh.c @@ -16,9 +16,9 @@ #include "fdlibm.h" #ifdef __STDC__ -static const float one=1.0, two=2.0, tiny = 1.0e-30; +static const volatile float one=1.0, two=2.0, tiny = 1.0e-30; #else -static float one=1.0, two=2.0, tiny = 1.0e-30; +static volatile float one=1.0, two=2.0, tiny = 1.0e-30; #endif #ifdef __STDC__
reply other threads:[~2021-06-04 18:43 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210604184311.7059038515F0@sourceware.org \ --to=jjohnstn@sourceware.org \ --cc=newlib-cvs@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: linkBe 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).