]> gcc.gnu.org Git - gcc.git/commitdiff
This patch simplifies pow (C, x) into exp (x * C1) if C > 0, C1 = log (C).
authorWilco Dijkstra <wdijkstr@arm.com>
Mon, 21 Aug 2017 14:46:34 +0000 (14:46 +0000)
committerWilco Dijkstra <wilco@gcc.gnu.org>
Mon, 21 Aug 2017 14:46:34 +0000 (14:46 +0000)
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

gcc/ChangeLog
gcc/match.pd

index 25b745208a78ce63bae54ee16469fe805b7b43ad..824d95470f6f64f54348cbe1e9c1460d9a16efcb 100644 (file)
@@ -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
index 0e36f46b914bc63c257cef47152ab1aa507963e5..a5552c5096de5100a882d52add6b620ba87c1f72 100644 (file)
@@ -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)
This page took 0.120427 seconds and 5 git commands to generate.