[33/46] Use stmt_vec_infos instead of vec_info/gimple stmt pairs

Message ID 87y3e1lzhu.fsf@arm.com
State New
Headers show
Series
  • Remove vinfo_for_stmt etc.
Related show

Commit Message

Richard Sandiford July 24, 2018, 10:06 a.m.
This patch makes vect_record_max_nunits and vect_record_base_alignment
take a stmt_vec_info instead of a vec_info/gimple pair.


2018-07-24  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* tree-vect-data-refs.c (vect_record_base_alignment): Replace vec_info
	and gimple stmt arguments with a stmt_vec_info.
	(vect_record_base_alignments): Update calls accordingly.
	* tree-vect-slp.c (vect_record_max_nunits): Replace vec_info
	and gimple stmt arguments with a stmt_vec_info.
	(vect_build_slp_tree_1): Remove vinfo argument and update call
	to vect_record_max_nunits.
	(vect_build_slp_tree_2): Update calls to vect_build_slp_tree_1
	and vect_record_max_nunits.

Comments

Richard Biener July 25, 2018, 10:06 a.m. | #1
On Tue, Jul 24, 2018 at 12:06 PM Richard Sandiford
<richard.sandiford@arm.com> wrote:
>

> This patch makes vect_record_max_nunits and vect_record_base_alignment

> take a stmt_vec_info instead of a vec_info/gimple pair.


OK

>

> 2018-07-24  Richard Sandiford  <richard.sandiford@arm.com>

>

> gcc/

>         * tree-vect-data-refs.c (vect_record_base_alignment): Replace vec_info

>         and gimple stmt arguments with a stmt_vec_info.

>         (vect_record_base_alignments): Update calls accordingly.

>         * tree-vect-slp.c (vect_record_max_nunits): Replace vec_info

>         and gimple stmt arguments with a stmt_vec_info.

>         (vect_build_slp_tree_1): Remove vinfo argument and update call

>         to vect_record_max_nunits.

>         (vect_build_slp_tree_2): Update calls to vect_build_slp_tree_1

>         and vect_record_max_nunits.

>

> Index: gcc/tree-vect-data-refs.c

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

> --- gcc/tree-vect-data-refs.c   2018-07-24 10:23:50.000602186 +0100

> +++ gcc/tree-vect-data-refs.c   2018-07-24 10:23:53.204573732 +0100

> @@ -794,14 +794,14 @@ vect_slp_analyze_instance_dependence (sl

>    return res;

>  }

>

> -/* Record in VINFO the base alignment guarantee given by DRB.  STMT is

> -   the statement that contains DRB, which is useful for recording in the

> -   dump file.  */

> +/* Record the base alignment guarantee given by DRB, which occurs

> +   in STMT_INFO.  */

>

>  static void

> -vect_record_base_alignment (vec_info *vinfo, gimple *stmt,

> +vect_record_base_alignment (stmt_vec_info stmt_info,

>                             innermost_loop_behavior *drb)

>  {

> +  vec_info *vinfo = stmt_info->vinfo;

>    bool existed;

>    innermost_loop_behavior *&entry

>      = vinfo->base_alignments.get_or_insert (drb->base_address, &existed);

> @@ -820,7 +820,7 @@ vect_record_base_alignment (vec_info *vi

>                            "  misalignment: %d\n", drb->base_misalignment);

>           dump_printf_loc (MSG_NOTE, vect_location,

>                            "  based on:     ");

> -         dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);

> +         dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt_info->stmt, 0);

>         }

>      }

>  }

> @@ -847,13 +847,13 @@ vect_record_base_alignments (vec_info *v

>           && STMT_VINFO_VECTORIZABLE (stmt_info)

>           && !STMT_VINFO_GATHER_SCATTER_P (stmt_info))

>         {

> -         vect_record_base_alignment (vinfo, stmt_info, &DR_INNERMOST (dr));

> +         vect_record_base_alignment (stmt_info, &DR_INNERMOST (dr));

>

>           /* If DR is nested in the loop that is being vectorized, we can also

>              record the alignment of the base wrt the outer loop.  */

>           if (loop && nested_in_vect_loop_p (loop, stmt_info))

>             vect_record_base_alignment

> -               (vinfo, stmt_info, &STMT_VINFO_DR_WRT_VEC_LOOP (stmt_info));

> +             (stmt_info, &STMT_VINFO_DR_WRT_VEC_LOOP (stmt_info));

>         }

>      }

>  }

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

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

> --- gcc/tree-vect-slp.c 2018-07-24 10:23:50.004602150 +0100

> +++ gcc/tree-vect-slp.c 2018-07-24 10:23:53.204573732 +0100

> @@ -609,14 +609,14 @@ compatible_calls_p (gcall *call1, gcall

>  }

>

>  /* A subroutine of vect_build_slp_tree for checking VECTYPE, which is the

> -   caller's attempt to find the vector type in STMT with the narrowest

> +   caller's attempt to find the vector type in STMT_INFO with the narrowest

>     element type.  Return true if VECTYPE is nonnull and if it is valid

> -   for VINFO.  When returning true, update MAX_NUNITS to reflect the

> -   number of units in VECTYPE.  VINFO, GORUP_SIZE and MAX_NUNITS are

> -   as for vect_build_slp_tree.  */

> +   for STMT_INFO.  When returning true, update MAX_NUNITS to reflect the

> +   number of units in VECTYPE.  GROUP_SIZE and MAX_NUNITS are as for

> +   vect_build_slp_tree.  */

>

>  static bool

> -vect_record_max_nunits (vec_info *vinfo, gimple *stmt, unsigned int group_size,

> +vect_record_max_nunits (stmt_vec_info stmt_info, unsigned int group_size,

>                         tree vectype, poly_uint64 *max_nunits)

>  {

>    if (!vectype)

> @@ -625,7 +625,8 @@ vect_record_max_nunits (vec_info *vinfo,

>         {

>           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,

>                            "Build SLP failed: unsupported data-type in ");

> -         dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);

> +         dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,

> +                           stmt_info->stmt, 0);

>           dump_printf (MSG_MISSED_OPTIMIZATION, "\n");

>         }

>        /* Fatal mismatch.  */

> @@ -636,7 +637,7 @@ vect_record_max_nunits (vec_info *vinfo,

>       before adjusting *max_nunits for basic-block vectorization.  */

>    poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (vectype);

>    unsigned HOST_WIDE_INT const_nunits;

> -  if (is_a <bb_vec_info> (vinfo)

> +  if (STMT_VINFO_BB_VINFO (stmt_info)

>        && (!nunits.is_constant (&const_nunits)

>           || const_nunits > group_size))

>      {

> @@ -696,7 +697,7 @@ vect_two_operations_perm_ok_p (vec<stmt_

>     to (B1 <= A1 ? X1 : Y1); or be inverted to (A1 < B1) ? Y1 : X1.  */

>

>  static bool

> -vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,

> +vect_build_slp_tree_1 (unsigned char *swap,

>                        vec<stmt_vec_info> stmts, unsigned int group_size,

>                        poly_uint64 *max_nunits, bool *matches,

>                        bool *two_operators)

> @@ -763,7 +764,7 @@ vect_build_slp_tree_1 (vec_info *vinfo,

>        if (!vect_get_vector_types_for_stmt (stmt_info, &vectype,

>                                            &nunits_vectype)

>           || (nunits_vectype

> -             && !vect_record_max_nunits (vinfo, stmt_info, group_size,

> +             && !vect_record_max_nunits (stmt_info, group_size,

>                                           nunits_vectype, max_nunits)))

>         {

>           /* Fatal mismatch.  */

> @@ -1207,8 +1208,7 @@ vect_build_slp_tree_2 (vec_info *vinfo,

>      {

>        tree scalar_type = TREE_TYPE (PHI_RESULT (stmt));

>        tree vectype = get_vectype_for_scalar_type (scalar_type);

> -      if (!vect_record_max_nunits (vinfo, stmt_info, group_size, vectype,

> -                                  max_nunits))

> +      if (!vect_record_max_nunits (stmt_info, group_size, vectype, max_nunits))

>         return NULL;

>

>        vect_def_type def_type = STMT_VINFO_DEF_TYPE (stmt_info);

> @@ -1241,7 +1241,7 @@ vect_build_slp_tree_2 (vec_info *vinfo,

>

>    bool two_operators = false;

>    unsigned char *swap = XALLOCAVEC (unsigned char, group_size);

> -  if (!vect_build_slp_tree_1 (vinfo, swap, stmts, group_size,

> +  if (!vect_build_slp_tree_1 (swap, stmts, group_size,

>                               &this_max_nunits, matches, &two_operators))

>      return NULL;

>

Patch

Index: gcc/tree-vect-data-refs.c
===================================================================
--- gcc/tree-vect-data-refs.c	2018-07-24 10:23:50.000602186 +0100
+++ gcc/tree-vect-data-refs.c	2018-07-24 10:23:53.204573732 +0100
@@ -794,14 +794,14 @@  vect_slp_analyze_instance_dependence (sl
   return res;
 }
 
-/* Record in VINFO the base alignment guarantee given by DRB.  STMT is
-   the statement that contains DRB, which is useful for recording in the
-   dump file.  */
+/* Record the base alignment guarantee given by DRB, which occurs
+   in STMT_INFO.  */
 
 static void
-vect_record_base_alignment (vec_info *vinfo, gimple *stmt,
+vect_record_base_alignment (stmt_vec_info stmt_info,
 			    innermost_loop_behavior *drb)
 {
+  vec_info *vinfo = stmt_info->vinfo;
   bool existed;
   innermost_loop_behavior *&entry
     = vinfo->base_alignments.get_or_insert (drb->base_address, &existed);
@@ -820,7 +820,7 @@  vect_record_base_alignment (vec_info *vi
 			   "  misalignment: %d\n", drb->base_misalignment);
 	  dump_printf_loc (MSG_NOTE, vect_location,
 			   "  based on:     ");
-	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
+	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt_info->stmt, 0);
 	}
     }
 }
@@ -847,13 +847,13 @@  vect_record_base_alignments (vec_info *v
 	  && STMT_VINFO_VECTORIZABLE (stmt_info)
 	  && !STMT_VINFO_GATHER_SCATTER_P (stmt_info))
 	{
-	  vect_record_base_alignment (vinfo, stmt_info, &DR_INNERMOST (dr));
+	  vect_record_base_alignment (stmt_info, &DR_INNERMOST (dr));
 
 	  /* If DR is nested in the loop that is being vectorized, we can also
 	     record the alignment of the base wrt the outer loop.  */
 	  if (loop && nested_in_vect_loop_p (loop, stmt_info))
 	    vect_record_base_alignment
-		(vinfo, stmt_info, &STMT_VINFO_DR_WRT_VEC_LOOP (stmt_info));
+	      (stmt_info, &STMT_VINFO_DR_WRT_VEC_LOOP (stmt_info));
 	}
     }
 }
Index: gcc/tree-vect-slp.c
===================================================================
--- gcc/tree-vect-slp.c	2018-07-24 10:23:50.004602150 +0100
+++ gcc/tree-vect-slp.c	2018-07-24 10:23:53.204573732 +0100
@@ -609,14 +609,14 @@  compatible_calls_p (gcall *call1, gcall
 }
 
 /* A subroutine of vect_build_slp_tree for checking VECTYPE, which is the
-   caller's attempt to find the vector type in STMT with the narrowest
+   caller's attempt to find the vector type in STMT_INFO with the narrowest
    element type.  Return true if VECTYPE is nonnull and if it is valid
-   for VINFO.  When returning true, update MAX_NUNITS to reflect the
-   number of units in VECTYPE.  VINFO, GORUP_SIZE and MAX_NUNITS are
-   as for vect_build_slp_tree.  */
+   for STMT_INFO.  When returning true, update MAX_NUNITS to reflect the
+   number of units in VECTYPE.  GROUP_SIZE and MAX_NUNITS are as for
+   vect_build_slp_tree.  */
 
 static bool
-vect_record_max_nunits (vec_info *vinfo, gimple *stmt, unsigned int group_size,
+vect_record_max_nunits (stmt_vec_info stmt_info, unsigned int group_size,
 			tree vectype, poly_uint64 *max_nunits)
 {
   if (!vectype)
@@ -625,7 +625,8 @@  vect_record_max_nunits (vec_info *vinfo,
 	{
 	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
 			   "Build SLP failed: unsupported data-type in ");
-	  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
+	  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+			    stmt_info->stmt, 0);
 	  dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
 	}
       /* Fatal mismatch.  */
@@ -636,7 +637,7 @@  vect_record_max_nunits (vec_info *vinfo,
      before adjusting *max_nunits for basic-block vectorization.  */
   poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (vectype);
   unsigned HOST_WIDE_INT const_nunits;
-  if (is_a <bb_vec_info> (vinfo)
+  if (STMT_VINFO_BB_VINFO (stmt_info)
       && (!nunits.is_constant (&const_nunits)
 	  || const_nunits > group_size))
     {
@@ -696,7 +697,7 @@  vect_two_operations_perm_ok_p (vec<stmt_
    to (B1 <= A1 ? X1 : Y1); or be inverted to (A1 < B1) ? Y1 : X1.  */
 
 static bool
-vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
+vect_build_slp_tree_1 (unsigned char *swap,
 		       vec<stmt_vec_info> stmts, unsigned int group_size,
 		       poly_uint64 *max_nunits, bool *matches,
 		       bool *two_operators)
@@ -763,7 +764,7 @@  vect_build_slp_tree_1 (vec_info *vinfo,
       if (!vect_get_vector_types_for_stmt (stmt_info, &vectype,
 					   &nunits_vectype)
 	  || (nunits_vectype
-	      && !vect_record_max_nunits (vinfo, stmt_info, group_size,
+	      && !vect_record_max_nunits (stmt_info, group_size,
 					  nunits_vectype, max_nunits)))
 	{
 	  /* Fatal mismatch.  */
@@ -1207,8 +1208,7 @@  vect_build_slp_tree_2 (vec_info *vinfo,
     {
       tree scalar_type = TREE_TYPE (PHI_RESULT (stmt));
       tree vectype = get_vectype_for_scalar_type (scalar_type);
-      if (!vect_record_max_nunits (vinfo, stmt_info, group_size, vectype,
-				   max_nunits))
+      if (!vect_record_max_nunits (stmt_info, group_size, vectype, max_nunits))
 	return NULL;
 
       vect_def_type def_type = STMT_VINFO_DEF_TYPE (stmt_info);
@@ -1241,7 +1241,7 @@  vect_build_slp_tree_2 (vec_info *vinfo,
 
   bool two_operators = false;
   unsigned char *swap = XALLOCAVEC (unsigned char, group_size);
-  if (!vect_build_slp_tree_1 (vinfo, swap, stmts, group_size,
+  if (!vect_build_slp_tree_1 (swap, stmts, group_size,
 			      &this_max_nunits, matches, &two_operators))
     return NULL;