From 16ef0a8cb7c913a09bfe5487688d45d42dae26ac Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 6 Mar 2018 08:06:44 +0100 Subject: [PATCH] re PR tree-optimization/84687 (error: invalid conversion in gimple call with -O3 and -ffast-math) PR tree-optimization/84687 * omp-simd-clone.c (simd_clone_create): Clear DECL_BUILT_IN_CLASS on new_node->decl. * match.pd (pow(C,x)*expN(y) -> expN(logN(C)*x+y)): New optimization. * gcc.dg/pr84687.c: New test. From-SVN: r258272 --- gcc/ChangeLog | 7 +++++++ gcc/match.pd | 10 ++++++++++ gcc/omp-simd-clone.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr84687.c | 19 +++++++++++++++++++ 5 files changed, 43 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr84687.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d90eaa52010..09123ede820 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-03-06 Jakub Jelinek + + PR tree-optimization/84687 + * omp-simd-clone.c (simd_clone_create): Clear DECL_BUILT_IN_CLASS + on new_node->decl. + * match.pd (pow(C,x)*expN(y) -> expN(logN(C)*x+y)): New optimization. + 2018-03-05 Bill Schmidt * config/rs6000/rs6000-builtin.def (rs6000_speculation_barrier): diff --git a/gcc/match.pd b/gcc/match.pd index b77f4ead3a8..5ba1304af4e 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -4030,6 +4030,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (exps (mult (logs @0) @1)) (exp2s (mult (log2s @0) @1))))))) + /* pow(C,x)*expN(y) -> expN(logN(C)*x+y) if C > 0. */ + (for pows (POW) + exps (EXP EXP2 EXP10 POW10) + logs (LOG LOG2 LOG10 LOG10) + (simplify + (mult:c (pows:s REAL_CST@0 @1) (exps:s @2)) + (if (real_compare (GT_EXPR, TREE_REAL_CST_PTR (@0), &dconst0) + && real_isfinite (TREE_REAL_CST_PTR (@0))) + (exps (plus (mult (logs @0) @1) @2))))) + (for sqrts (SQRT) cbrts (CBRT) pows (POW) diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c index 56832ebf22d..b15adf0bada 100644 --- a/gcc/omp-simd-clone.c +++ b/gcc/omp-simd-clone.c @@ -456,6 +456,8 @@ simd_clone_create (struct cgraph_node *old_node) if (new_node == NULL) return new_node; + DECL_BUILT_IN_CLASS (new_node->decl) = NOT_BUILT_IN; + DECL_FUNCTION_CODE (new_node->decl) = (enum built_in_function) 0; TREE_PUBLIC (new_node->decl) = TREE_PUBLIC (old_node->decl); DECL_COMDAT (new_node->decl) = DECL_COMDAT (old_node->decl); DECL_WEAK (new_node->decl) = DECL_WEAK (old_node->decl); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3de87e95b56..2e507037951 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-06 Jakub Jelinek + + PR tree-optimization/84687 + * gcc.dg/pr84687.c: New test. + 2018-03-06 Alexandre Oliva PR c++/84231 diff --git a/gcc/testsuite/gcc.dg/pr84687.c b/gcc/testsuite/gcc.dg/pr84687.c new file mode 100644 index 00000000000..f3ac9ac27dd --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr84687.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/84687 */ +/* { dg-do compile } */ +/* { dg-options "-Ofast" } */ + +int a[64], b; +double pow (double, double); +__attribute__((__simd__)) double exp (double); + +void +foo (double x) +{ + int i; + double c = exp (x); + for (i = 0; i < 64; i++) + { + b = i; + a[i] = pow (12.0, b) * pow (c, i); + } +} -- 2.30.2