tree-ssa-math-opts: Move PROP_gimple_opt_math from sincos pass to powcabs [PR109301]

Message ID ZCK8eTKhp3GZY0UC@tucnak
State Unresolved
Headers
Series tree-ssa-math-opts: Move PROP_gimple_opt_math from sincos pass to powcabs [PR109301] |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Jakub Jelinek March 28, 2023, 10:07 a.m. UTC
  Hi!

On Tue, Mar 28, 2023 at 09:23:23AM +0000, Richard Biener wrote:
> But as said, the fix is probably to move the pass property.

After looking into it in more detail I agree with you.
powcabs is a pass in the spot sincos was happening before, so the
only change was defer the sin+cos simplification into cexpi to a later
new pass (except for the name moving with it) and none of the
canonicalize_math_p () guarded simplification in match.pd seem to rely
on those sin+cos -> cexpi simplifications and canonicalize_math_p is
the only user of this property.

The following patch fixes the testcase, ok for trunk if it passes
bootstrap/regtest?

Or should I add the match.pd change as well?

2023-03-28  Jakub Jelinek  <jakub@redhat.com>
	    Richard Biener  <rguenther@suse.de>

	PR tree-optimization/109301
	* tree-ssa-math-opts.cc (pass_data_cse_sincos): Change
	properties_provided from PROP_gimple_opt_math to 0.
	(pass_data_expand_powcabs): Change properties_provided from 0 to
	PROP_gimple_opt_math.

	* gcc.dg/pr109301.c: New test.


	Jakub
  

Comments

Richard Biener March 28, 2023, 10:53 a.m. UTC | #1
On Tue, 28 Mar 2023, Jakub Jelinek wrote:

> Hi!
> 
> On Tue, Mar 28, 2023 at 09:23:23AM +0000, Richard Biener wrote:
> > But as said, the fix is probably to move the pass property.
> 
> After looking into it in more detail I agree with you.
> powcabs is a pass in the spot sincos was happening before, so the
> only change was defer the sin+cos simplification into cexpi to a later
> new pass (except for the name moving with it) and none of the
> canonicalize_math_p () guarded simplification in match.pd seem to rely
> on those sin+cos -> cexpi simplifications and canonicalize_math_p is
> the only user of this property.
> 
> The following patch fixes the testcase, ok for trunk if it passes
> bootstrap/regtest?

OK.

> Or should I add the match.pd change as well?

I think it shouldn't be necessary.

Thanks,
Richard.

> 2023-03-28  Jakub Jelinek  <jakub@redhat.com>
> 	    Richard Biener  <rguenther@suse.de>
> 
> 	PR tree-optimization/109301
> 	* tree-ssa-math-opts.cc (pass_data_cse_sincos): Change
> 	properties_provided from PROP_gimple_opt_math to 0.
> 	(pass_data_expand_powcabs): Change properties_provided from 0 to
> 	PROP_gimple_opt_math.
> 
> 	* gcc.dg/pr109301.c: New test.
> 
> --- gcc/tree-ssa-math-opts.cc.jj	2023-03-12 22:36:06.355178083 +0100
> +++ gcc/tree-ssa-math-opts.cc	2023-03-28 11:57:36.576699748 +0200
> @@ -2237,7 +2237,7 @@ const pass_data pass_data_cse_sincos =
>    OPTGROUP_NONE, /* optinfo_flags */
>    TV_TREE_SINCOS, /* tv_id */
>    PROP_ssa, /* properties_required */
> -  PROP_gimple_opt_math, /* properties_provided */
> +  0, /* properties_provided */
>    0, /* properties_destroyed */
>    0, /* todo_flags_start */
>    TODO_update_ssa, /* todo_flags_finish */
> @@ -2331,7 +2331,7 @@ const pass_data pass_data_expand_powcabs
>    OPTGROUP_NONE, /* optinfo_flags */
>    TV_TREE_POWCABS, /* tv_id */
>    PROP_ssa, /* properties_required */
> -  0, /* properties_provided */
> +  PROP_gimple_opt_math, /* properties_provided */
>    0, /* properties_destroyed */
>    0, /* todo_flags_start */
>    TODO_update_ssa, /* todo_flags_finish */
> --- gcc/testsuite/gcc.dg/pr109301.c.jj	2023-03-28 11:56:34.130615683 +0200
> +++ gcc/testsuite/gcc.dg/pr109301.c	2023-03-28 11:56:34.130615683 +0200
> @@ -0,0 +1,13 @@
> +/* PR tree-optimization/109301 */
> +/* { dg-do compile } */
> +/* { dg-options "-O3 -ffast-math" } */
> +
> +double x[256];
> +
> +void
> +foo (void)
> +{
> +  for (int i = 0; i < 256; ++i)
> +    for (int j = 0; j < 8; ++j)
> +      x[i] = __builtin_pow (x[i], 0.5);
> +}
> 
> 	Jakub
> 
>
  

Patch

--- gcc/tree-ssa-math-opts.cc.jj	2023-03-12 22:36:06.355178083 +0100
+++ gcc/tree-ssa-math-opts.cc	2023-03-28 11:57:36.576699748 +0200
@@ -2237,7 +2237,7 @@  const pass_data pass_data_cse_sincos =
   OPTGROUP_NONE, /* optinfo_flags */
   TV_TREE_SINCOS, /* tv_id */
   PROP_ssa, /* properties_required */
-  PROP_gimple_opt_math, /* properties_provided */
+  0, /* properties_provided */
   0, /* properties_destroyed */
   0, /* todo_flags_start */
   TODO_update_ssa, /* todo_flags_finish */
@@ -2331,7 +2331,7 @@  const pass_data pass_data_expand_powcabs
   OPTGROUP_NONE, /* optinfo_flags */
   TV_TREE_POWCABS, /* tv_id */
   PROP_ssa, /* properties_required */
-  0, /* properties_provided */
+  PROP_gimple_opt_math, /* properties_provided */
   0, /* properties_destroyed */
   0, /* todo_flags_start */
   TODO_update_ssa, /* todo_flags_finish */
--- gcc/testsuite/gcc.dg/pr109301.c.jj	2023-03-28 11:56:34.130615683 +0200
+++ gcc/testsuite/gcc.dg/pr109301.c	2023-03-28 11:56:34.130615683 +0200
@@ -0,0 +1,13 @@ 
+/* PR tree-optimization/109301 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -ffast-math" } */
+
+double x[256];
+
+void
+foo (void)
+{
+  for (int i = 0; i < 256; ++i)
+    for (int j = 0; j < 8; ++j)
+      x[i] = __builtin_pow (x[i], 0.5);
+}