public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH] Fix a brown paper bag bug in my recent match.pd change (PR middle-end/84309)
  2018-02-13 21:49 [PATCH] Fix a brown paper bag bug in my recent match.pd change (PR middle-end/84309) Jakub Jelinek
@ 2018-02-13 18:01 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2018-02-13 18:01 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] Fix a brown paper bag bug in my recent match.pd change (PR middle-end/84309)
@ 2018-02-13 21:49 Jakub Jelinek
  2018-02-13 18:01 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2018-02-13 21:49 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

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?

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-13 21:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-13 21:49 [PATCH] Fix a brown paper bag bug in my recent match.pd change (PR middle-end/84309) Jakub Jelinek
2018-02-13 18:01 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).