This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[PATCH v2] Don't do double divide in powf.
- From: Jim Wilson <jimw at sifive dot com>
- To: newlib at sourceware dot org
- Cc: Jim Wilson <jimw at sifive dot com>
- Date: Tue, 12 Dec 2017 11:39:13 -0800
- Subject: [PATCH v2] Don't do double divide in powf.
- Authentication-results: sourceware.org; auth=none
- References: <20171212034521.8556-1-jimw@sifive.com>
Updated patch to use 0.0f/0.0f to avoid the divdf3 call.
Tested same way as before, with a testcase that triggers the code and
make check.
OK?
newlib/
* libm/math/wf_pow.c (powf): Use 0.0f instead 0.0 in divide.
---
newlib/libm/math/wf_pow.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/newlib/libm/math/wf_pow.c b/newlib/libm/math/wf_pow.c
index be453558b..7f4c6b651 100644
--- a/newlib/libm/math/wf_pow.c
+++ b/newlib/libm/math/wf_pow.c
@@ -108,7 +108,9 @@
if (_LIB_VERSION == _SVID_)
exc.retval = 0.0;
else
- exc.retval = 0.0/0.0; /* X/Open allow NaN */
+ /* Use a float divide, to avoid a soft-float double
+ divide call on single-float only targets. */
+ exc.retval = (0.0f/0.0f); /* X/Open allow NaN */
if (_LIB_VERSION == _POSIX_)
errno = EDOM;
else if (!matherr(&exc)) {
--
2.14.1