From e83fe013941bf8b3129a8ceb19e14ea7d8c51aa2 Mon Sep 17 00:00:00 2001 From: Wilco Dijkstra Date: Mon, 21 Aug 2017 14:46:34 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 4 ++++ gcc/match.pd | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 25b745208a7..824d95470f6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2017-08-21 Wilco Dijkstra + + * match.pd: Add pow (C, x) simplification. + 2017-08-21 Richard Biener PR tree-optimization/81900 diff --git a/gcc/match.pd b/gcc/match.pd index 0e36f46b914..a5552c5096d 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) -- 2.30.2