[02/13] Pass vec_perm_indices by reference

Message ID 87a7yrmrc4.fsf@linaro.org
State New
Headers show
Series
  • Make VEC_PERM_EXPR work for variable-length vectors
Related show

Commit Message

Richard Sandiford Dec. 9, 2017, 11:09 p.m.
This patch makes functions take vec_perm_indices by reference rather
than value, since a later patch will turn vec_perm_indices into a class
that would be more expensive to copy.


2017-12-06  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
	* fold-const.c (fold_vec_perm): Take a const vec_perm_indices &
	instead of vec_perm_indices.
	* tree-vectorizer.h (vect_gen_perm_mask_any): Likewise,
	(vect_gen_perm_mask_checked): Likewise,
	* tree-vect-stmts.c (vect_gen_perm_mask_any): Likewise,
	(vect_gen_perm_mask_checked): Likewise,

Comments

Richard Biener Dec. 12, 2017, 2:23 p.m. | #1
On Sun, Dec 10, 2017 at 12:09 AM, Richard Sandiford
<richard.sandiford@linaro.org> wrote:
> This patch makes functions take vec_perm_indices by reference rather

> than value, since a later patch will turn vec_perm_indices into a class

> that would be more expensive to copy.


Ok.

>

> 2017-12-06  Richard Sandiford  <richard.sandiford@linaro.org>

>

> gcc/

>         * fold-const.c (fold_vec_perm): Take a const vec_perm_indices &

>         instead of vec_perm_indices.

>         * tree-vectorizer.h (vect_gen_perm_mask_any): Likewise,

>         (vect_gen_perm_mask_checked): Likewise,

>         * tree-vect-stmts.c (vect_gen_perm_mask_any): Likewise,

>         (vect_gen_perm_mask_checked): Likewise,

>

> Index: gcc/fold-const.c

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

> --- gcc/fold-const.c    2017-12-09 22:47:11.840391388 +0000

> +++ gcc/fold-const.c    2017-12-09 22:47:19.119312754 +0000

> @@ -8801,7 +8801,7 @@ vec_cst_ctor_to_array (tree arg, unsigne

>     NULL_TREE otherwise.  */

>

>  static tree

> -fold_vec_perm (tree type, tree arg0, tree arg1, vec_perm_indices sel)

> +fold_vec_perm (tree type, tree arg0, tree arg1, const vec_perm_indices &sel)

>  {

>    unsigned int i;

>    bool need_ctor = false;

> Index: gcc/tree-vectorizer.h

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

> --- gcc/tree-vectorizer.h       2017-12-09 22:47:11.840391388 +0000

> +++ gcc/tree-vectorizer.h       2017-12-09 22:47:19.120312754 +0000

> @@ -1204,8 +1204,8 @@ extern void vect_get_load_cost (struct d

>  extern void vect_get_store_cost (struct data_reference *, int,

>                                  unsigned int *, stmt_vector_for_cost *);

>  extern bool vect_supportable_shift (enum tree_code, tree);

> -extern tree vect_gen_perm_mask_any (tree, vec_perm_indices);

> -extern tree vect_gen_perm_mask_checked (tree, vec_perm_indices);

> +extern tree vect_gen_perm_mask_any (tree, const vec_perm_indices &);

> +extern tree vect_gen_perm_mask_checked (tree, const vec_perm_indices &);

>  extern void optimize_mask_stores (struct loop*);

>

>  /* In tree-vect-data-refs.c.  */

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

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

> --- gcc/tree-vect-stmts.c       2017-12-09 22:47:11.840391388 +0000

> +++ gcc/tree-vect-stmts.c       2017-12-09 22:47:19.119312754 +0000

> @@ -6506,7 +6506,7 @@ vectorizable_store (gimple *stmt, gimple

>     vect_gen_perm_mask_checked.  */

>

>  tree

> -vect_gen_perm_mask_any (tree vectype, vec_perm_indices sel)

> +vect_gen_perm_mask_any (tree vectype, const vec_perm_indices &sel)

>  {

>    tree mask_elt_type, mask_type;

>

> @@ -6527,7 +6527,7 @@ vect_gen_perm_mask_any (tree vectype, ve

>     i.e. that the target supports the pattern _for arbitrary input vectors_.  */

>

>  tree

> -vect_gen_perm_mask_checked (tree vectype, vec_perm_indices sel)

> +vect_gen_perm_mask_checked (tree vectype, const vec_perm_indices &sel)

>  {

>    gcc_assert (can_vec_perm_p (TYPE_MODE (vectype), false, &sel));

>    return vect_gen_perm_mask_any (vectype, sel);

Patch

Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c	2017-12-09 22:47:11.840391388 +0000
+++ gcc/fold-const.c	2017-12-09 22:47:19.119312754 +0000
@@ -8801,7 +8801,7 @@  vec_cst_ctor_to_array (tree arg, unsigne
    NULL_TREE otherwise.  */
 
 static tree
-fold_vec_perm (tree type, tree arg0, tree arg1, vec_perm_indices sel)
+fold_vec_perm (tree type, tree arg0, tree arg1, const vec_perm_indices &sel)
 {
   unsigned int i;
   bool need_ctor = false;
Index: gcc/tree-vectorizer.h
===================================================================
--- gcc/tree-vectorizer.h	2017-12-09 22:47:11.840391388 +0000
+++ gcc/tree-vectorizer.h	2017-12-09 22:47:19.120312754 +0000
@@ -1204,8 +1204,8 @@  extern void vect_get_load_cost (struct d
 extern void vect_get_store_cost (struct data_reference *, int,
 				 unsigned int *, stmt_vector_for_cost *);
 extern bool vect_supportable_shift (enum tree_code, tree);
-extern tree vect_gen_perm_mask_any (tree, vec_perm_indices);
-extern tree vect_gen_perm_mask_checked (tree, vec_perm_indices);
+extern tree vect_gen_perm_mask_any (tree, const vec_perm_indices &);
+extern tree vect_gen_perm_mask_checked (tree, const vec_perm_indices &);
 extern void optimize_mask_stores (struct loop*);
 
 /* In tree-vect-data-refs.c.  */
Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c	2017-12-09 22:47:11.840391388 +0000
+++ gcc/tree-vect-stmts.c	2017-12-09 22:47:19.119312754 +0000
@@ -6506,7 +6506,7 @@  vectorizable_store (gimple *stmt, gimple
    vect_gen_perm_mask_checked.  */
 
 tree
-vect_gen_perm_mask_any (tree vectype, vec_perm_indices sel)
+vect_gen_perm_mask_any (tree vectype, const vec_perm_indices &sel)
 {
   tree mask_elt_type, mask_type;
 
@@ -6527,7 +6527,7 @@  vect_gen_perm_mask_any (tree vectype, ve
    i.e. that the target supports the pattern _for arbitrary input vectors_.  */
 
 tree
-vect_gen_perm_mask_checked (tree vectype, vec_perm_indices sel)
+vect_gen_perm_mask_checked (tree vectype, const vec_perm_indices &sel)
 {
   gcc_assert (can_vec_perm_p (TYPE_MODE (vectype), false, &sel));
   return vect_gen_perm_mask_any (vectype, sel);