Discussion:
[PATCH] Remove log2 define
Wilco Dijkstra
2018-08-24 14:37:05 UTC
Permalink
Since newlib now has a fast implementation of log2, remove a define which
avoids calling log2. The define makes math code slower and less accurate,
so removing it is best.

Build OK on AArch64, OK for commit?

--
diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h
index 893a5d0645148af0dd0a48f7e73504e07363a840..2d17dd13e52ae1893beba8c9a2565d7682dbbf89 100644
--- a/newlib/libc/include/math.h
+++ b/newlib/libc/include/math.h
@@ -329,9 +329,6 @@ extern double lgamma (double);
extern double erf (double);
extern double erfc (double);
extern double log2 (double);
-#if !defined(__cplusplus)
-#define log2(x) (log (x) / _M_LN2)
-#endif

#ifndef __math_68881
extern double hypot (double, double);
Corinna Vinschen
2018-08-24 14:45:59 UTC
Permalink
Post by Wilco Dijkstra
Since newlib now has a fast implementation of log2,
Only if !__OBSOLETE_MATH
Post by Wilco Dijkstra
remove a define which
avoids calling log2. The define makes math code slower and less accurate,
so removing it is best.
Build OK on AArch64, OK for commit?
--
diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h
index 893a5d0645148af0dd0a48f7e73504e07363a840..2d17dd13e52ae1893beba8c9a2565d7682dbbf89 100644
--- a/newlib/libc/include/math.h
+++ b/newlib/libc/include/math.h
@@ -329,9 +329,6 @@ extern double lgamma (double);
extern double erf (double);
extern double erfc (double);
extern double log2 (double);
-#if !defined(__cplusplus)
-#define log2(x) (log (x) / _M_LN2)
-#endif
#ifndef __math_68881
extern double hypot (double, double);
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
Wilco Dijkstra
2018-08-24 16:04:11 UTC
Permalink
Post by Corinna Vinschen
Post by Wilco Dijkstra
Since newlib now has a fast implementation of log2,
Only if !__OBSOLETE_MATH
Is there any reason keep that old code, particularly for the rewritten double
precision functions? We now have a log2 that is both fast, accurate and
correct, which isn't true for the obsolete version.

Wilco
Corinna Vinschen
2018-08-27 10:44:58 UTC
Permalink
Post by Wilco Dijkstra
Post by Corinna Vinschen
Post by Wilco Dijkstra
Since newlib now has a fast implementation of log2,
Only if !__OBSOLETE_MATH
Is there any reason keep that old code, particularly for the rewritten double
precision functions? We now have a log2 that is both fast, accurate and
correct, which isn't true for the obsolete version.
If you want to make it default for all targets, I guess you can go
ahead and send patches to remove the obsolete code.


Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
Tamar Christina
2018-09-05 11:54:13 UTC
Permalink
-----Original Message-----
Behalf Of Corinna Vinschen
Sent: Monday, August 27, 2018 11:45
Subject: Re: [PATCH] Remove log2 define
Post by Wilco Dijkstra
Post by Corinna Vinschen
Post by Wilco Dijkstra
Since newlib now has a fast implementation of log2,
Only if !__OBSOLETE_MATH
Is there any reason keep that old code, particularly for the rewritten
double precision functions? We now have a log2 that is both fast,
accurate and correct, which isn't true for the obsolete version.
If you want to make it default for all targets, I guess you can go ahead and
send patches to remove the obsolete code.
Should that action actually block this one? We've had cases where this optimization isn't safe
when the user compiles this header and their code with fast-math. So I'd say there's an actual
bug here as well.

Regards,
Tamar.
Corinna
--
Corinna Vinschen
Cygwin
Loading...