re PR middle-end/84309 (Wrong-code with -ffast-math)
authorJakub Jelinek <jakub@redhat.com>
Tue, 13 Feb 2018 20:22:50 +0000 (21:22 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 13 Feb 2018 20:22:50 +0000 (21:22 +0100)
PR middle-end/84309
* match.pd (pow(C,x) -> exp(log(C)*x)): Use exp2s and log2s instead
of exps and logs in the use_exp2 case.

* gcc.dg/pr84309-2.c: New test.

From-SVN: r257634

gcc/ChangeLog
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr84309-2.c [new file with mode: 0644]

index e2f71932f77b1fab1ec842aedcb70180c3cc6ef2..f60fb1d2b869dc6584367ea46d1c7c1ce423de39 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/84309
+       * match.pd (pow(C,x) -> exp(log(C)*x)): Use exp2s and log2s instead
+       of exps and logs in the use_exp2 case.
+
 2018-02-13  Jeff Law  <law@redhat.com>
 
        * config/rl/rl78.c (rl78_attribute_table): Fix terminator and
index 833effa9b67119f7c829a7a7ea452afb356dcc09..f7597110c4bbd2fe4cd0b0e45dae8d83284750fb 100644 (file)
@@ -4021,7 +4021,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
       /* As libmvec doesn't have a vectorized exp2, defer optimizing
         this until after vectorization.  */
       (if (canonicalize_math_after_vectorization_p ())
-       (exps (mult (logs @0) @1))))))))
+       (exp2s (mult (log2s @0) @1))))))))
 
  (for sqrts (SQRT)
       cbrts (CBRT)
index b11f10a6179e3c4facbcc8e35c690adc5c14a2d2..cd5ab819fea543754717b248275bfff35b3f7756 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/84309
+       * gcc.dg/pr84309-2.c: New test.
+
 2018-02-12  Richard Sandiford  <richard.sandiford@linaro.org>
 
        PR tree-optimization/84321
diff --git a/gcc/testsuite/gcc.dg/pr84309-2.c b/gcc/testsuite/gcc.dg/pr84309-2.c
new file mode 100644 (file)
index 0000000..ced55d4
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR middle-end/84309 */
+/* { dg-do compile } */
+/* { dg-options "-Ofast -fdump-tree-optimized" } */
+
+double
+foo (double x)
+{
+  return __builtin_pow (2.0, x);
+}
+
+/* { dg-final { scan-tree-dump "__builtin_exp2 " "optimized" { target *-*-linux* *-*-gnu* } } } */