public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Simplify pow with constant
@ 2017-08-04 11:23 Wilco Dijkstra
  2017-08-04 12:26 ` Alexander Monakov
  0 siblings, 1 reply; 13+ messages in thread
From: Wilco Dijkstra @ 2017-08-04 11:23 UTC (permalink / raw)
  To: GCC Patches; +Cc: nd

This patch simplifies pow (C, x) into exp (x * C1), where C1 = log (C).
Do this only for fast-math as accuracy is reduced.  This is much faster
since pow is more complex than exp - with a current GLIBC the speedup
is more than 7 times for this transformation.

ChangeLog:
2017-08-04  Wilco Dijkstra  <wdijkstr@arm.com>

	* match.pd: Add pow (C, x) simplification.

--

diff --git a/gcc/match.pd b/gcc/match.pd
index e98db52af84946cf579c6434e06d450713a47162..96486aa1f512fe32d85a1de95c46523263ea1b6d 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3548,6 +3548,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
    (logs (pows @0 @1))
    (mult @1 (logs @0))))
 
+ /* pow(C,x) -> exp(log(C)*x).  */
+ (for pows (POW)
+      exps (EXP)
+      logs (LOG)
+  (simplify
+   (pows REAL_CST@0 @1)
+   (exps (mult (logs @0) @1))))
+
  (for sqrts (SQRT)
       cbrts (CBRT)
       pows (POW)

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

end of thread, other threads:[~2017-08-25 13:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-04 11:23 [PATCH] Simplify pow with constant Wilco Dijkstra
2017-08-04 12:26 ` Alexander Monakov
2017-08-04 12:44   ` Richard Biener
2017-08-04 15:28     ` Wilco Dijkstra
2017-08-17 14:19       ` [PATCH v2] " Wilco Dijkstra
2017-08-17 16:58         ` Alexander Monakov
2017-08-18  8:29           ` Richard Biener
2017-08-18 13:53           ` Wilco Dijkstra
2017-08-18 14:05             ` Richard Biener
2017-08-25  4:21           ` Jeff Law
2017-08-25  0:31         ` Jeff Law
2017-08-25 14:37           ` Wilco Dijkstra
2017-08-04 22:38     ` [PATCH] " Joseph Myers

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