public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Convert 0.0/0.0 to NAN
@ 2017-04-19 23:50 Richard Allen
  2017-04-20  0:01 ` Richard Allen
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Allen @ 2017-04-19 23:50 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 383 bytes --]

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-rint-to-rintf.patch --]
[-- Type: text/x-patch, Size: 1105 bytes --]

From 2369a552cf62dfb53f14978587a338072f6abd2c Mon Sep 17 00:00:00 2001
From: Richard <rsaxvc@rsaxvc.net>
Date: Wed, 19 Apr 2017 18:37:17 -0500
Subject: [PATCH] Convert rint() to rintf()

This was causing an unnecessary increase
in precision, as well as additional function
calls to do float->double conversion on
platforms with only a single-precision FPU.
---
 newlib/libm/math/wf_pow.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/newlib/libm/math/wf_pow.c b/newlib/libm/math/wf_pow.c
index bd9de0ad0..5b79dd151 100644
--- a/newlib/libm/math/wf_pow.c
+++ b/newlib/libm/math/wf_pow.c
@@ -126,11 +126,11 @@
 		    if (_LIB_VERSION == _SVID_) {
 		       exc.retval = HUGE;
 		       y *= 0.5;
-		       if(x<0.0&&rint(y)!=y) exc.retval = -HUGE;
+		       if(x<0.0&&rintf(y)!=y) exc.retval = -HUGE;
 		    } else {
 		       exc.retval = HUGE_VAL;
                        y *= 0.5;
-		       if(x<0.0&&rint(y)!=y) exc.retval = -HUGE_VAL;
+		       if(x<0.0&&rintf(y)!=y) exc.retval = -HUGE_VAL;
 		    }
 		    if (_LIB_VERSION == _POSIX_)
 		        errno = ERANGE;
-- 
2.11.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-20  0:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-19 23:50 [PATCH] Convert 0.0/0.0 to NAN Richard Allen
2017-04-20  0:01 ` Richard Allen
2017-04-20  0:25   ` Craig Howland

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).