From 9aa484f5a9c74509ecf9722a518b962f0634dad2 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 13 Feb 2018 21:22:50 +0100 Subject: [PATCH] re PR middle-end/84309 (Wrong-code with -ffast-math) 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 | 6 ++++++ gcc/match.pd | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr84309-2.c | 11 +++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr84309-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e2f71932f77..f60fb1d2b86 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-02-13 Jakub Jelinek + + 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 * config/rl/rl78.c (rl78_attribute_table): Fix terminator and diff --git a/gcc/match.pd b/gcc/match.pd index 833effa9b67..f7597110c4b 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b11f10a6179..cd5ab819fea 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-13 Jakub Jelinek + + PR middle-end/84309 + * gcc.dg/pr84309-2.c: New test. + 2018-02-12 Richard Sandiford 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 index 00000000000..ced55d4a646 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr84309-2.c @@ -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* } } } */ -- 2.30.2