This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix a brown paper bag bug in my recent match.pd change (PR middle-end/84309)
- From: Richard Biener <rguenther at suse dot de>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 13 Feb 2018 19:01:02 +0100
- Subject: Re: [PATCH] Fix a brown paper bag bug in my recent match.pd change (PR middle-end/84309)
- Authentication-results: sourceware.org; auth=none
- References: <20180213175436.GT5867@tucnak>
On February 13, 2018 6:54:36 PM GMT+01:00, Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>When changing my recent match.pd fix to defer the -> exp2 (log2 (C) *
>x)
>optimization until later, I've swapped the two patterns and changed
>the first one to use exps and logs, but forgot to change the second one
>to use exp2s and log2s. For the testcase in the patch it actually
>didn't
>make a difference, it was enough that we deferred optimizing it
>(because
>we shortly afterwards propagated constants into the pow and constant
>folded
>it).
>
>This patch adds a testcase that verifies it is done properly.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
OK.
Richard.
>
>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.
>
> * gcc.dg/pr84309-2.c: New test.
>
>--- gcc/match.pd.jj 2018-02-13 12:14:08.108314686 +0100
>+++ gcc/match.pd 2018-02-13 12:28:59.958328523 +0100
>@@ -4032,7 +4032,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)
>--- gcc/testsuite/gcc.dg/pr84309-2.c.jj 2018-02-13 12:30:25.208304990
>+0100
>+++ gcc/testsuite/gcc.dg/pr84309-2.c 2018-02-13 12:31:35.959285452
>+0100
>@@ -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* } } } */
>
> Jakub