]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/84687 (error: invalid conversion in gimple call with -O3...
authorJakub Jelinek <jakub@redhat.com>
Tue, 6 Mar 2018 07:06:44 +0000 (08:06 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 6 Mar 2018 07:06:44 +0000 (08:06 +0100)
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
gcc/match.pd
gcc/omp-simd-clone.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr84687.c [new file with mode: 0644]

index d90eaa52010b40616f9c995079a050958c6e0654..09123ede82061fbb4c18c4066c54b2178af5a3db 100644 (file)
@@ -1,3 +1,10 @@
+2018-03-06  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <wschmidt@linux.vnet.ibm.com>
 
        * config/rs6000/rs6000-builtin.def (rs6000_speculation_barrier):
index b77f4ead3a84e22e10add6919e6826fcd9dd679a..5ba1304af4e15349689da6dd7dc857915fa2d8c6 100644 (file)
@@ -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)
index 56832ebf22d17af73b6c25e61eec7c71b83a86bc..b15adf0bada40e2f083668cf3d2390852b15d238 100644 (file)
@@ -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);
index 3de87e95b567f5a1ab1f550215ee36d707162a69..2e5070379511012aaec98fa46fd76aece7f14ab9 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/84687
+       * gcc.dg/pr84687.c: New test.
+
 2018-03-06  Alexandre Oliva <aoliva@redhat.com>
 
        PR c++/84231
diff --git a/gcc/testsuite/gcc.dg/pr84687.c b/gcc/testsuite/gcc.dg/pr84687.c
new file mode 100644 (file)
index 0000000..f3ac9ac
--- /dev/null
@@ -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);
+    }
+}