public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Avoid more temporaries in IVOPTs
@ 2021-04-14 11:40 Richard Biener
  2021-04-23  8:28 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Biener @ 2021-04-14 11:40 UTC (permalink / raw)
  To: gcc-patches

This avoids use of valid_gimple_rhs_p and instead gimplifies to
such a RHS, avoiding more SSA copies being generated by IVOPTs.

Bootstrapped and tested on x86_64-unknown-linux-gnu, queued for stage1

2021-04-14  Richard Biener  <rguenther@suse.de>

	* tree-ssa-loop-ivopts.c (rewrite_use_nonlinear_expr): Avoid
	valid_gimple_rhs_p by instead gimplifying to one.
---
 gcc/tree-ssa-loop-ivopts.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 4012ae3f19d..12a8a49a307 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -7286,12 +7286,13 @@ rewrite_use_nonlinear_expr (struct ivopts_data *data,
     }
 
   comp = fold_convert (type, comp);
-  if (!valid_gimple_rhs_p (comp)
-      || (gimple_code (use->stmt) != GIMPLE_PHI
-	  /* We can't allow re-allocating the stmt as it might be pointed
-	     to still.  */
-	  && (get_gimple_rhs_num_ops (TREE_CODE (comp))
-	      >= gimple_num_ops (gsi_stmt (bsi)))))
+  comp = force_gimple_operand (comp, &seq, false, NULL);
+  gimple_seq_add_seq (&stmt_list, seq);
+  if (gimple_code (use->stmt) != GIMPLE_PHI
+      /* We can't allow re-allocating the stmt as it might be pointed
+	 to still.  */
+      && (get_gimple_rhs_num_ops (TREE_CODE (comp))
+	  >= gimple_num_ops (gsi_stmt (bsi))))
     {
       comp = force_gimple_operand (comp, &seq, true, NULL);
       gimple_seq_add_seq (&stmt_list, seq);
-- 
2.26.2

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

* Re: [PATCH] Avoid more temporaries in IVOPTs
  2021-04-14 11:40 [PATCH] Avoid more temporaries in IVOPTs Richard Biener
@ 2021-04-23  8:28 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2021-04-23  8:28 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches

On Wed, Apr 14, 2021 at 2:41 PM Richard Biener <rguenther@suse.de> wrote:
>
> This avoids use of valid_gimple_rhs_p and instead gimplifies to
> such a RHS, avoiding more SSA copies being generated by IVOPTs.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, queued for stage1

g:b26485f1af45423980b7bc1206411cf4b8bb84b6

> 2021-04-14  Richard Biener  <rguenther@suse.de>
>
>         * tree-ssa-loop-ivopts.c (rewrite_use_nonlinear_expr): Avoid
>         valid_gimple_rhs_p by instead gimplifying to one.
> ---
>  gcc/tree-ssa-loop-ivopts.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
> index 4012ae3f19d..12a8a49a307 100644
> --- a/gcc/tree-ssa-loop-ivopts.c
> +++ b/gcc/tree-ssa-loop-ivopts.c
> @@ -7286,12 +7286,13 @@ rewrite_use_nonlinear_expr (struct ivopts_data *data,
>      }
>
>    comp = fold_convert (type, comp);
> -  if (!valid_gimple_rhs_p (comp)
> -      || (gimple_code (use->stmt) != GIMPLE_PHI
> -         /* We can't allow re-allocating the stmt as it might be pointed
> -            to still.  */
> -         && (get_gimple_rhs_num_ops (TREE_CODE (comp))
> -             >= gimple_num_ops (gsi_stmt (bsi)))))
> +  comp = force_gimple_operand (comp, &seq, false, NULL);
> +  gimple_seq_add_seq (&stmt_list, seq);
> +  if (gimple_code (use->stmt) != GIMPLE_PHI
> +      /* We can't allow re-allocating the stmt as it might be pointed
> +        to still.  */
> +      && (get_gimple_rhs_num_ops (TREE_CODE (comp))
> +         >= gimple_num_ops (gsi_stmt (bsi))))
>      {
>        comp = force_gimple_operand (comp, &seq, true, NULL);
>        gimple_seq_add_seq (&stmt_list, seq);
> --
> 2.26.2

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

end of thread, other threads:[~2021-04-23  8:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-14 11:40 [PATCH] Avoid more temporaries in IVOPTs Richard Biener
2021-04-23  8:28 ` 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).