From: Richard Allen <rsaxvc@rsaxvc.net>
To: newlib@sourceware.org
Subject: Re: [PATCH] Convert 0.0/0.0 to NAN
Date: Thu, 20 Apr 2017 00:01:00 -0000 [thread overview]
Message-ID: <CAMY0PLVuZCC_H1EJKwMMzcNr6ZVof7HFGRuaiW8UmVhQhqnnaw@mail.gmail.com> (raw)
In-Reply-To: <CAMY0PLWxEvHZ7q1m=MW=dV0JjzOrzQ4B277nxgZrmW7AfvnMJQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 542 bytes --]
Whoops, that was the wrong patch. Attached is correct patch.
On Wed, Apr 19, 2017 at 6:50 PM, Richard Allen <rsaxvc@rsaxvc.net> wrote:
> With newlib's default compiler flags(-O2 and whatnot),
> the GCC I'm using creates calls to __aeabi_(f|d)div.
> This causes a little extra register copying
> and an unnecessary branch.
>
> Additionally, __aeabi_?div may throw exceptions,
> which is probably not what we want a
> simple assignment to do.
>
> Compiler version tested:
> arm-none-eabi-gcc (15:5.4.1+svn241155-1) 5.4.1 20160919
>
> -Richard
[-- Attachment #2: 0001-Convert-0.0-0.0-to-NAN.patch --]
[-- Type: text/x-patch, Size: 6642 bytes --]
From 823701d0b25a00b892f55498f611a5222a1b80ee Mon Sep 17 00:00:00 2001
From: Richard <rsaxvc@rsaxvc.net>
Date: Wed, 19 Apr 2017 18:24:22 -0500
Subject: [PATCH 1/2] Convert 0.0/0.0 to NAN
With newlib's default compiler flags(-O2 and whatnot),
the GCC I'm using creates calls to __aeabi_fdiv
or __aeabi_ddiv. This causes a little extra
register allocation and an unnecessary branch.
Additionally, __aeabi_*div may throw exceptions,
which is almost certainly not what we want those
lines to do.
Compiler version tested:
arm-none-eabi-gcc (15:5.4.1+svn241155-1) 5.4.1 20160919
---
newlib/libm/math/w_acosh.c | 2 +-
newlib/libm/math/w_atanh.c | 2 +-
newlib/libm/math/w_fmod.c | 2 +-
newlib/libm/math/w_pow.c | 2 +-
newlib/libm/math/w_remainder.c | 2 +-
newlib/libm/math/w_sqrt.c | 2 +-
newlib/libm/math/wf_acosh.c | 2 +-
newlib/libm/math/wf_atanh.c | 2 +-
newlib/libm/math/wf_fmod.c | 2 +-
newlib/libm/math/wf_pow.c | 2 +-
newlib/libm/math/wf_remainder.c | 2 +-
newlib/libm/math/wf_sqrt.c | 2 +-
12 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/newlib/libm/math/w_acosh.c b/newlib/libm/math/w_acosh.c
index 93032600b..f40d9f291 100644
--- a/newlib/libm/math/w_acosh.c
+++ b/newlib/libm/math/w_acosh.c
@@ -106,7 +106,7 @@ MATHREF
exc.name = "acosh";
exc.err = 0;
exc.arg1 = exc.arg2 = x;
- exc.retval = 0.0/0.0;
+ exc.retval = NAN;
if (_LIB_VERSION == _POSIX_)
errno = EDOM;
else if (!matherr(&exc)) {
diff --git a/newlib/libm/math/w_atanh.c b/newlib/libm/math/w_atanh.c
index 07fd45962..9ffa29e48 100644
--- a/newlib/libm/math/w_atanh.c
+++ b/newlib/libm/math/w_atanh.c
@@ -106,7 +106,7 @@ QUICKREF
exc.name = "atanh";
exc.err = 0;
exc.arg1 = exc.arg2 = x;
- exc.retval = 0.0/0.0;
+ exc.retval = NAN;
if (_LIB_VERSION == _POSIX_)
errno = EDOM;
else if (!matherr(&exc)) {
diff --git a/newlib/libm/math/w_fmod.c b/newlib/libm/math/w_fmod.c
index f9f72c745..616a291bd 100644
--- a/newlib/libm/math/w_fmod.c
+++ b/newlib/libm/math/w_fmod.c
@@ -90,7 +90,7 @@ PORTABILITY
if (_LIB_VERSION == _SVID_)
exc.retval = x;
else
- exc.retval = 0.0/0.0;
+ exc.retval = NAN;
if (_LIB_VERSION == _POSIX_)
errno = EDOM;
else if (!matherr(&exc)) {
diff --git a/newlib/libm/math/w_pow.c b/newlib/libm/math/w_pow.c
index ebf7be328..685507124 100644
--- a/newlib/libm/math/w_pow.c
+++ b/newlib/libm/math/w_pow.c
@@ -157,7 +157,7 @@ PORTABILITY
if (_LIB_VERSION == _SVID_)
exc.retval = 0.0;
else
- exc.retval = 0.0/0.0; /* X/Open allow NaN */
+ exc.retval = NAN; /* X/Open allow NaN */
if (_LIB_VERSION == _POSIX_)
errno = EDOM;
else if (!matherr(&exc)) {
diff --git a/newlib/libm/math/w_remainder.c b/newlib/libm/math/w_remainder.c
index e4c196716..01245755c 100644
--- a/newlib/libm/math/w_remainder.c
+++ b/newlib/libm/math/w_remainder.c
@@ -74,7 +74,7 @@ PORTABILITY
exc.err = 0;
exc.arg1 = x;
exc.arg2 = y;
- exc.retval = 0.0/0.0;
+ exc.retval = NAN;
if (_LIB_VERSION == _POSIX_)
errno = EDOM;
else if (!matherr(&exc)) {
diff --git a/newlib/libm/math/w_sqrt.c b/newlib/libm/math/w_sqrt.c
index 23a793ce7..b2b1f8d78 100644
--- a/newlib/libm/math/w_sqrt.c
+++ b/newlib/libm/math/w_sqrt.c
@@ -76,7 +76,7 @@ PORTABILITY
if (_LIB_VERSION == _SVID_)
exc.retval = 0.0;
else
- exc.retval = 0.0/0.0;
+ exc.retval = NAN;
if (_LIB_VERSION == _POSIX_)
errno = EDOM;
else if (!matherr(&exc)) {
diff --git a/newlib/libm/math/wf_acosh.c b/newlib/libm/math/wf_acosh.c
index fc8ec3a0a..3c25447e8 100644
--- a/newlib/libm/math/wf_acosh.c
+++ b/newlib/libm/math/wf_acosh.c
@@ -41,7 +41,7 @@
exc.name = "acoshf";
exc.err = 0;
exc.arg1 = exc.arg2 = (double)x;
- exc.retval = 0.0/0.0;
+ exc.retval = NAN;
if (_LIB_VERSION == _POSIX_)
errno = EDOM;
else if (!matherr(&exc)) {
diff --git a/newlib/libm/math/wf_atanh.c b/newlib/libm/math/wf_atanh.c
index 565630411..a6a0a28cf 100644
--- a/newlib/libm/math/wf_atanh.c
+++ b/newlib/libm/math/wf_atanh.c
@@ -41,7 +41,7 @@
exc.name = "atanhf";
exc.err = 0;
exc.arg1 = exc.arg2 = (double)x;
- exc.retval = 0.0/0.0;
+ exc.retval = NAN;
if (_LIB_VERSION == _POSIX_)
errno = EDOM;
else if (!matherr(&exc)) {
diff --git a/newlib/libm/math/wf_fmod.c b/newlib/libm/math/wf_fmod.c
index 030ca3e7a..b14339a20 100644
--- a/newlib/libm/math/wf_fmod.c
+++ b/newlib/libm/math/wf_fmod.c
@@ -44,7 +44,7 @@
if (_LIB_VERSION == _SVID_)
exc.retval = x;
else
- exc.retval = 0.0/0.0;
+ exc.retval = NAN;
if (_LIB_VERSION == _POSIX_)
errno = EDOM;
else if (!matherr(&exc)) {
diff --git a/newlib/libm/math/wf_pow.c b/newlib/libm/math/wf_pow.c
index a30f8808e..bd9de0ad0 100644
--- a/newlib/libm/math/wf_pow.c
+++ b/newlib/libm/math/wf_pow.c
@@ -107,7 +107,7 @@
if (_LIB_VERSION == _SVID_)
exc.retval = 0.0;
else
- exc.retval = 0.0/0.0; /* X/Open allow NaN */
+ exc.retval = NAN; /* X/Open allow NaN */
if (_LIB_VERSION == _POSIX_)
errno = EDOM;
else if (!matherr(&exc)) {
diff --git a/newlib/libm/math/wf_remainder.c b/newlib/libm/math/wf_remainder.c
index f38c23785..48c395f9c 100644
--- a/newlib/libm/math/wf_remainder.c
+++ b/newlib/libm/math/wf_remainder.c
@@ -41,7 +41,7 @@
exc.err = 0;
exc.arg1 = (double)x;
exc.arg2 = (double)y;
- exc.retval = 0.0/0.0;
+ exc.retval = NAN;
if (_LIB_VERSION == _POSIX_)
errno = EDOM;
else if (!matherr(&exc)) {
diff --git a/newlib/libm/math/wf_sqrt.c b/newlib/libm/math/wf_sqrt.c
index 4536ba0ac..96814bd73 100644
--- a/newlib/libm/math/wf_sqrt.c
+++ b/newlib/libm/math/wf_sqrt.c
@@ -43,7 +43,7 @@
if (_LIB_VERSION == _SVID_)
exc.retval = 0.0;
else
- exc.retval = 0.0/0.0;
+ exc.retval = NAN;
if (_LIB_VERSION == _POSIX_)
errno = EDOM;
else if (!matherr(&exc)) {
--
2.11.0
next prev parent reply other threads:[~2017-04-20 0:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-19 23:50 Richard Allen
2017-04-20 0:01 ` Richard Allen [this message]
2017-04-20 0:25 ` Craig Howland
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=CAMY0PLVuZCC_H1EJKwMMzcNr6ZVof7HFGRuaiW8UmVhQhqnnaw@mail.gmail.com \
--to=rsaxvc@rsaxvc.net \
--cc=newlib@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).