aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorWilco Dijkstra <wdijkstr@arm.com>2017-08-21 14:46:34 +0000
committerWilco Dijkstra <wilco@gcc.gnu.org>2017-08-21 14:46:34 +0000
commite83fe013941bf8b3129a8ceb19e14ea7d8c51aa2 (patch)
tree81c6e0100e7b9cb8ab7fa98c986144cf9fd74c74 /gcc
parent13c6f12c0e948f975ad5a0efb79340c9dc39eaee (diff)
downloadgcc-e83fe013941bf8b3129a8ceb19e14ea7d8c51aa2.zip
gcc-e83fe013941bf8b3129a8ceb19e14ea7d8c51aa2.tar.gz
gcc-e83fe013941bf8b3129a8ceb19e14ea7d8c51aa2.tar.bz2
This patch simplifies pow (C, x) into exp (x * C1) if C > 0, C1 = log (C).
Do this only for fast-math as accuracy is reduced. This is much faster since pow is more complex than exp. gcc/ * match.pd: Add pow (C, x) simplification From-SVN: r251230
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/match.pd10
2 files changed, 14 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 25b7452..824d954 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2017-08-21 Wilco Dijkstra <wdijkstr@arm.com>
+
+ * match.pd: Add pow (C, x) simplification.
+
2017-08-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/81900
diff --git a/gcc/match.pd b/gcc/match.pd
index 0e36f46..a5552c5 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3622,6 +3622,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(logs (pows @0 @1))
(mult @1 (logs @0))))
+ /* pow(C,x) -> exp(log(C)*x) if C > 0. */
+ (for pows (POW)
+ exps (EXP)
+ logs (LOG)
+ (simplify
+ (pows REAL_CST@0 @1)
+ (if (real_compare (GT_EXPR, TREE_REAL_CST_PTR (@0), &dconst0)
+ && real_isfinite (TREE_REAL_CST_PTR (@0)))
+ (exps (mult (logs @0) @1)))))
+
(for sqrts (SQRT)
cbrts (CBRT)
pows (POW)