public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Avoid unnecessary creation of VEC_COND_EXPR in the vectorizer
@ 2016-01-22 22:09 Jakub Jelinek
  2016-01-23  7:31 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2016-01-22 22:09 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

Hi!

I've noticed we create a VEC_COND_EXPR tree just to grab the arguments from
it to construct a ternary gimple assign.

The following patch fixes that by creating the ternary gimple assign
directly.  Bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2016-01-22  Jakub Jelinek  <jakub@redhat.com>

	* tree-vect-stmts.c (vectorizable_condition): Build a VEC_COND_EXPR
	directly instead of building a temporary tree.

--- gcc/tree-vect-stmts.c.jj	2016-01-20 15:39:08.000000000 +0100
+++ gcc/tree-vect-stmts.c	2016-01-22 10:25:59.744444625 +0100
@@ -7478,7 +7478,7 @@ vectorizable_condition (gimple *stmt, gi
   tree comp_vectype = NULL_TREE;
   tree vec_cond_lhs = NULL_TREE, vec_cond_rhs = NULL_TREE;
   tree vec_then_clause = NULL_TREE, vec_else_clause = NULL_TREE;
-  tree vec_compare, vec_cond_expr;
+  tree vec_compare;
   tree new_temp;
   loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
   enum vect_def_type dt, dts[4];
@@ -7691,12 +7691,10 @@ vectorizable_condition (gimple *stmt, gi
 	      vec_compare = build2 (TREE_CODE (cond_expr), vec_cmp_type,
 				    vec_cond_lhs, vec_cond_rhs);
 	    }
-          vec_cond_expr = build3 (VEC_COND_EXPR, vectype,
- 		         vec_compare, vec_then_clause, vec_else_clause);
-
-          new_stmt = gimple_build_assign (vec_dest, vec_cond_expr);
-          new_temp = make_ssa_name (vec_dest, new_stmt);
-          gimple_assign_set_lhs (new_stmt, new_temp);
+          new_temp = make_ssa_name (vec_dest);
+          new_stmt = gimple_build_assign (new_temp, VEC_COND_EXPR,
+					  vec_compare, vec_then_clause,
+					  vec_else_clause);
           vect_finish_stmt_generation (stmt, new_stmt, gsi);
           if (slp_node)
             SLP_TREE_VEC_STMTS (slp_node).quick_push (new_stmt);

	Jakub

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

* Re: [PATCH] Avoid unnecessary creation of VEC_COND_EXPR in the vectorizer
  2016-01-22 22:09 [PATCH] Avoid unnecessary creation of VEC_COND_EXPR in the vectorizer Jakub Jelinek
@ 2016-01-23  7:31 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2016-01-23  7:31 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On January 22, 2016 11:09:06 PM GMT+01:00, Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>I've noticed we create a VEC_COND_EXPR tree just to grab the arguments
>from
>it to construct a ternary gimple assign.
>
>The following patch fixes that by creating the ternary gimple assign
>directly.  Bootstrapped/regtested on x86_64-linux and i686-linux, ok
>for
>trunk?

OK.

Thanks,
Richard.

>2016-01-22  Jakub Jelinek  <jakub@redhat.com>
>
>	* tree-vect-stmts.c (vectorizable_condition): Build a VEC_COND_EXPR
>	directly instead of building a temporary tree.
>
>--- gcc/tree-vect-stmts.c.jj	2016-01-20 15:39:08.000000000 +0100
>+++ gcc/tree-vect-stmts.c	2016-01-22 10:25:59.744444625 +0100
>@@ -7478,7 +7478,7 @@ vectorizable_condition (gimple *stmt, gi
>   tree comp_vectype = NULL_TREE;
>   tree vec_cond_lhs = NULL_TREE, vec_cond_rhs = NULL_TREE;
>   tree vec_then_clause = NULL_TREE, vec_else_clause = NULL_TREE;
>-  tree vec_compare, vec_cond_expr;
>+  tree vec_compare;
>   tree new_temp;
>   loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
>   enum vect_def_type dt, dts[4];
>@@ -7691,12 +7691,10 @@ vectorizable_condition (gimple *stmt, gi
> 	      vec_compare = build2 (TREE_CODE (cond_expr), vec_cmp_type,
> 				    vec_cond_lhs, vec_cond_rhs);
> 	    }
>-          vec_cond_expr = build3 (VEC_COND_EXPR, vectype,
>- 		         vec_compare, vec_then_clause, vec_else_clause);
>-
>-          new_stmt = gimple_build_assign (vec_dest, vec_cond_expr);
>-          new_temp = make_ssa_name (vec_dest, new_stmt);
>-          gimple_assign_set_lhs (new_stmt, new_temp);
>+          new_temp = make_ssa_name (vec_dest);
>+          new_stmt = gimple_build_assign (new_temp, VEC_COND_EXPR,
>+					  vec_compare, vec_then_clause,
>+					  vec_else_clause);
>           vect_finish_stmt_generation (stmt, new_stmt, gsi);
>           if (slp_node)
>             SLP_TREE_VEC_STMTS (slp_node).quick_push (new_stmt);
>
>	Jakub


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

end of thread, other threads:[~2016-01-23  7:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-22 22:09 [PATCH] Avoid unnecessary creation of VEC_COND_EXPR in the vectorizer Jakub Jelinek
2016-01-23  7:31 ` 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).