diff mbox series

Make more use of gimple-fold.h in tree-vect-loop.c

Message ID 87fubpwmhw.fsf@linaro.org
State Accepted
Commit dccf43aed37281a7bb91a7984a75470ad62eb0f1
Headers show
Series Make more use of gimple-fold.h in tree-vect-loop.c | expand

Commit Message

Richard Sandiford Sept. 14, 2017, 11:25 a.m. UTC
This patch makes the vectoriser use the gimple-fold.h routines
in more cases, instead of vect_init_vector.  Later patches want
to use the same interface to handle variable-length vectors.

Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu.
OK to install?

Richard


2017-09-14  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

gcc/
	* tree-vect-loop.c (vectorizable_induction): Use gimple_build instead
	of vect_init_vector.

Comments

Richard Biener Sept. 14, 2017, 1:43 p.m. UTC | #1
On Thu, Sep 14, 2017 at 1:25 PM, Richard Sandiford
<richard.sandiford@linaro.org> wrote:
> This patch makes the vectoriser use the gimple-fold.h routines

> in more cases, instead of vect_init_vector.  Later patches want

> to use the same interface to handle variable-length vectors.

>

> Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu.

> OK to install?


Ok.

Richard.

> Richard

>

>

> 2017-09-14  Richard Sandiford  <richard.sandiford@linaro.org>

>             Alan Hayward  <alan.hayward@arm.com>

>             David Sherwood  <david.sherwood@arm.com>

>

> gcc/

>         * tree-vect-loop.c (vectorizable_induction): Use gimple_build instead

>         of vect_init_vector.

>

> Index: gcc/tree-vect-loop.c

> ===================================================================

> --- gcc/tree-vect-loop.c        2017-09-14 11:26:37.599804415 +0100

> +++ gcc/tree-vect-loop.c        2017-09-14 11:27:16.962234838 +0100

> @@ -6839,18 +6839,21 @@ vectorizable_induction (gimple *phi,

>      {

>        /* iv_loop is the loop to be vectorized. Generate:

>           vec_step = [VF*S, VF*S, VF*S, VF*S]  */

> +      gimple_seq seq = NULL;

>        if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (step_expr)))

>         {

>           expr = build_int_cst (integer_type_node, vf);

> -         expr = fold_convert (TREE_TYPE (step_expr), expr);

> +         expr = gimple_build (&seq, FLOAT_EXPR, TREE_TYPE (step_expr), expr);

>         }

>        else

>         expr = build_int_cst (TREE_TYPE (step_expr), vf);

> -      new_name = fold_build2 (MULT_EXPR, TREE_TYPE (step_expr),

> -                             expr, step_expr);

> -      if (TREE_CODE (step_expr) == SSA_NAME)

> -       new_name = vect_init_vector (phi, new_name,

> -                                    TREE_TYPE (step_expr), NULL);

> +      new_name = gimple_build (&seq, MULT_EXPR, TREE_TYPE (step_expr),

> +                              expr, step_expr);

> +      if (seq)

> +       {

> +         new_bb = gsi_insert_seq_on_edge_immediate (pe, seq);

> +         gcc_assert (!new_bb);

> +       }

>      }

>

>    t = unshare_expr (new_name);

> @@ -6899,6 +6902,7 @@ vectorizable_induction (gimple *phi,

>

>    if (ncopies > 1)

>      {

> +      gimple_seq seq = NULL;

>        stmt_vec_info prev_stmt_vinfo;

>        /* FORNOW. This restriction should be relaxed.  */

>        gcc_assert (!nested_in_vect_loop);

> @@ -6907,15 +6911,18 @@ vectorizable_induction (gimple *phi,

>        if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (step_expr)))

>         {

>           expr = build_int_cst (integer_type_node, nunits);

> -         expr = fold_convert (TREE_TYPE (step_expr), expr);

> +         expr = gimple_build (&seq, FLOAT_EXPR, TREE_TYPE (step_expr), expr);

>         }

>        else

>         expr = build_int_cst (TREE_TYPE (step_expr), nunits);

> -      new_name = fold_build2 (MULT_EXPR, TREE_TYPE (step_expr),

> -                             expr, step_expr);

> -      if (TREE_CODE (step_expr) == SSA_NAME)

> -       new_name = vect_init_vector (phi, new_name,

> -                                    TREE_TYPE (step_expr), NULL);

> +      new_name = gimple_build (&seq, MULT_EXPR, TREE_TYPE (step_expr),

> +                              expr, step_expr);

> +      if (seq)

> +       {

> +         new_bb = gsi_insert_seq_on_edge_immediate (pe, seq);

> +         gcc_assert (!new_bb);

> +       }

> +

>        t = unshare_expr (new_name);

>        gcc_assert (CONSTANT_CLASS_P (new_name)

>                   || TREE_CODE (new_name) == SSA_NAME);
diff mbox series

Patch

Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c	2017-09-14 11:26:37.599804415 +0100
+++ gcc/tree-vect-loop.c	2017-09-14 11:27:16.962234838 +0100
@@ -6839,18 +6839,21 @@  vectorizable_induction (gimple *phi,
     {
       /* iv_loop is the loop to be vectorized. Generate:
 	  vec_step = [VF*S, VF*S, VF*S, VF*S]  */
+      gimple_seq seq = NULL;
       if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (step_expr)))
 	{
 	  expr = build_int_cst (integer_type_node, vf);
-	  expr = fold_convert (TREE_TYPE (step_expr), expr);
+	  expr = gimple_build (&seq, FLOAT_EXPR, TREE_TYPE (step_expr), expr);
 	}
       else
 	expr = build_int_cst (TREE_TYPE (step_expr), vf);
-      new_name = fold_build2 (MULT_EXPR, TREE_TYPE (step_expr),
-			      expr, step_expr);
-      if (TREE_CODE (step_expr) == SSA_NAME)
-	new_name = vect_init_vector (phi, new_name,
-				     TREE_TYPE (step_expr), NULL);
+      new_name = gimple_build (&seq, MULT_EXPR, TREE_TYPE (step_expr),
+			       expr, step_expr);
+      if (seq)
+	{
+	  new_bb = gsi_insert_seq_on_edge_immediate (pe, seq);
+	  gcc_assert (!new_bb);
+	}
     }
 
   t = unshare_expr (new_name);
@@ -6899,6 +6902,7 @@  vectorizable_induction (gimple *phi,
 
   if (ncopies > 1)
     {
+      gimple_seq seq = NULL;
       stmt_vec_info prev_stmt_vinfo;
       /* FORNOW. This restriction should be relaxed.  */
       gcc_assert (!nested_in_vect_loop);
@@ -6907,15 +6911,18 @@  vectorizable_induction (gimple *phi,
       if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (step_expr)))
 	{
 	  expr = build_int_cst (integer_type_node, nunits);
-	  expr = fold_convert (TREE_TYPE (step_expr), expr);
+	  expr = gimple_build (&seq, FLOAT_EXPR, TREE_TYPE (step_expr), expr);
 	}
       else
 	expr = build_int_cst (TREE_TYPE (step_expr), nunits);
-      new_name = fold_build2 (MULT_EXPR, TREE_TYPE (step_expr),
-			      expr, step_expr);
-      if (TREE_CODE (step_expr) == SSA_NAME)
-	new_name = vect_init_vector (phi, new_name,
-				     TREE_TYPE (step_expr), NULL);
+      new_name = gimple_build (&seq, MULT_EXPR, TREE_TYPE (step_expr),
+			       expr, step_expr);
+      if (seq)
+	{
+	  new_bb = gsi_insert_seq_on_edge_immediate (pe, seq);
+	  gcc_assert (!new_bb);
+	}
+
       t = unshare_expr (new_name);
       gcc_assert (CONSTANT_CLASS_P (new_name)
 		  || TREE_CODE (new_name) == SSA_NAME);