This gets rid of slp_void_p and moves vect_get_place_in_interleaving_chain
next to its only user.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2013-04-09  Richard Biener  <rguent...@suse.de>

        * tree-vectorizer.h (slp_void_p): Remove.
        (slp_tree): Typedef before _slp_tree declaration.
        (struct _slp_tree): Use a vector of slp_tree as children.
        (vect_get_place_in_interleaving_chain): Remove.
        * tree-vect-data-refs.c (vect_get_place_in_interleaving_chain):
        Move ...
        * tree-vect-slp.c (vect_get_place_in_interleaving_chain): ... here
        and make static.
        (vect_free_slp_tree, vect_print_slp_tree, vect_mark_slp_stmts,
        vect_mark_slp_stmts_relevant, vect_slp_rearrange_stmts,
        vect_detect_hybrid_slp_stmts, vect_slp_analyze_node_operations,
        vect_schedule_slp_instance, vect_remove_slp_scalar_calls):
        Use slp_node instead of slp_void_p and adjust.

Index: gcc/tree-vect-data-refs.c
===================================================================
*** gcc/tree-vect-data-refs.c   (revision 197621)
--- gcc/tree-vect-data-refs.c   (working copy)
*************** vect_get_smallest_scalar_type (gimple st
*** 129,159 ****
  }
  
  
- /* Find the place of the data-ref in STMT in the interleaving chain that 
starts
-    from FIRST_STMT.  Return -1 if the data-ref is not a part of the chain.  */
- 
- int
- vect_get_place_in_interleaving_chain (gimple stmt, gimple first_stmt)
- {
-   gimple next_stmt = first_stmt;
-   int result = 0;
- 
-   if (first_stmt != GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)))
-     return -1;
- 
-   while (next_stmt && next_stmt != stmt)
-     {
-       result++;
-       next_stmt = GROUP_NEXT_ELEMENT (vinfo_for_stmt (next_stmt));
-     }
- 
-   if (next_stmt)
-     return result;
-   else
-     return -1;
- }
- 
- 
  /* Check if data references pointed by DR_I and DR_J are same or
     belong to same interleaving group.  Return FALSE if drs are
     different, otherwise return TRUE.  */
--- 129,134 ----
Index: gcc/tree-vect-slp.c
===================================================================
*** gcc/tree-vect-slp.c (revision 197621)
--- gcc/tree-vect-slp.c (working copy)
*************** static void
*** 67,79 ****
  vect_free_slp_tree (slp_tree node)
  {
    int i;
!   slp_void_p child;
  
    if (!node)
      return;
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     vect_free_slp_tree ((slp_tree) child);
  
    SLP_TREE_CHILDREN (node).release ();
    SLP_TREE_SCALAR_STMTS (node).release ();
--- 67,79 ----
  vect_free_slp_tree (slp_tree node)
  {
    int i;
!   slp_tree child;
  
    if (!node)
      return;
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     vect_free_slp_tree (child);
  
    SLP_TREE_CHILDREN (node).release ();
    SLP_TREE_SCALAR_STMTS (node).release ();
*************** vect_free_oprnd_info (vec<slp_oprnd_info
*** 168,173 ****
--- 168,198 ----
  }
  
  
+ /* Find the place of the data-ref in STMT in the interleaving chain that 
starts
+    from FIRST_STMT.  Return -1 if the data-ref is not a part of the chain.  */
+ 
+ static int
+ vect_get_place_in_interleaving_chain (gimple stmt, gimple first_stmt)
+ {
+   gimple next_stmt = first_stmt;
+   int result = 0;
+ 
+   if (first_stmt != GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)))
+     return -1;
+ 
+   do
+     {
+       if (next_stmt == stmt)
+       return result;
+       result++;
+       next_stmt = GROUP_NEXT_ELEMENT (vinfo_for_stmt (next_stmt));
+     }
+   while (next_stmt);
+ 
+   return -1;
+ }
+ 
+ 
  /* Get the defs for the rhs of STMT (collect them in OPRNDS_INFO), check that
     they are of a valid type and that they match the defs of the first stmt of
     the SLP group (stored in OPRNDS_INFO).  */
*************** vect_print_slp_tree (int dump_kind, slp_
*** 991,997 ****
  {
    int i;
    gimple stmt;
!   slp_void_p child;
  
    if (!node)
      return;
--- 1016,1022 ----
  {
    int i;
    gimple stmt;
!   slp_tree child;
  
    if (!node)
      return;
*************** vect_print_slp_tree (int dump_kind, slp_
*** 1005,1011 ****
    dump_printf (dump_kind, "\n");
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     vect_print_slp_tree (dump_kind, (slp_tree) child);
  }
  
  
--- 1030,1036 ----
    dump_printf (dump_kind, "\n");
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     vect_print_slp_tree (dump_kind, child);
  }
  
  
*************** vect_mark_slp_stmts (slp_tree node, enum
*** 1019,1025 ****
  {
    int i;
    gimple stmt;
!   slp_void_p child;
  
    if (!node)
      return;
--- 1044,1050 ----
  {
    int i;
    gimple stmt;
!   slp_tree child;
  
    if (!node)
      return;
*************** vect_mark_slp_stmts (slp_tree node, enum
*** 1029,1035 ****
        STMT_SLP_TYPE (vinfo_for_stmt (stmt)) = mark;
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     vect_mark_slp_stmts ((slp_tree) child, mark, j);
  }
  
  
--- 1054,1060 ----
        STMT_SLP_TYPE (vinfo_for_stmt (stmt)) = mark;
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     vect_mark_slp_stmts (child, mark, j);
  }
  
  
*************** vect_mark_slp_stmts_relevant (slp_tree n
*** 1041,1047 ****
    int i;
    gimple stmt;
    stmt_vec_info stmt_info;
!   slp_void_p child;
  
    if (!node)
      return;
--- 1066,1072 ----
    int i;
    gimple stmt;
    stmt_vec_info stmt_info;
!   slp_tree child;
  
    if (!node)
      return;
*************** vect_mark_slp_stmts_relevant (slp_tree n
*** 1055,1061 ****
      }
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     vect_mark_slp_stmts_relevant ((slp_tree) child);
  }
  
  
--- 1080,1086 ----
      }
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     vect_mark_slp_stmts_relevant (child);
  }
  
  
*************** vect_slp_rearrange_stmts (slp_tree node,
*** 1129,1154 ****
  {
    gimple stmt;
    vec<gimple> tmp_stmts;
!   unsigned int index, i;
!   slp_void_p child;
! 
!   if (!node)
!     return;
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     vect_slp_rearrange_stmts ((slp_tree) child, group_size, permutation);
  
    gcc_assert (group_size == SLP_TREE_SCALAR_STMTS (node).length ());
    tmp_stmts.create (group_size);
! 
!   for (i = 0; i < group_size; i++)
!     tmp_stmts.safe_push (NULL);
  
    FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), i, stmt)
!     {
!       index = permutation[i];
!       tmp_stmts[index] = stmt;
!     }
  
    SLP_TREE_SCALAR_STMTS (node).release ();
    SLP_TREE_SCALAR_STMTS (node) = tmp_stmts;
--- 1154,1171 ----
  {
    gimple stmt;
    vec<gimple> tmp_stmts;
!   unsigned int i;
!   slp_tree child;
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     vect_slp_rearrange_stmts (child, group_size, permutation);
  
    gcc_assert (group_size == SLP_TREE_SCALAR_STMTS (node).length ());
    tmp_stmts.create (group_size);
!   tmp_stmts.quick_grow_cleared (group_size);
  
    FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), i, stmt)
!     tmp_stmts[permutation[i]] = stmt;
  
    SLP_TREE_SCALAR_STMTS (node).release ();
    SLP_TREE_SCALAR_STMTS (node) = tmp_stmts;
*************** vect_detect_hybrid_slp_stmts (slp_tree n
*** 1824,1830 ****
    imm_use_iterator imm_iter;
    gimple use_stmt;
    stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt);
!   slp_void_p child;
    loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_vinfo);
    struct loop *loop = NULL;
    bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_vinfo);
--- 1841,1847 ----
    imm_use_iterator imm_iter;
    gimple use_stmt;
    stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt);
!   slp_tree child;
    loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_vinfo);
    struct loop *loop = NULL;
    bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_vinfo);
*************** vect_detect_hybrid_slp_stmts (slp_tree n
*** 1855,1861 ****
          vect_mark_slp_stmts (node, hybrid, i);
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     vect_detect_hybrid_slp_stmts ((slp_tree) child);
  }
  
  
--- 1872,1878 ----
          vect_mark_slp_stmts (node, hybrid, i);
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     vect_detect_hybrid_slp_stmts (child);
  }
  
  
*************** vect_slp_analyze_node_operations (bb_vec
*** 1953,1965 ****
    bool dummy;
    int i;
    gimple stmt;
!   slp_void_p child;
  
    if (!node)
      return true;
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     if (!vect_slp_analyze_node_operations (bb_vinfo, (slp_tree) child))
        return false;
  
    FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), i, stmt)
--- 1970,1982 ----
    bool dummy;
    int i;
    gimple stmt;
!   slp_tree child;
  
    if (!node)
      return true;
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     if (!vect_slp_analyze_node_operations (bb_vinfo, child))
        return false;
  
    FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), i, stmt)
*************** vect_schedule_slp_instance (slp_tree nod
*** 3014,3027 ****
    tree vectype;
    int i;
    slp_tree loads_node;
!   slp_void_p child;
  
    if (!node)
      return false;
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     vect_schedule_slp_instance ((slp_tree) child, instance,
!                                 vectorization_factor);
  
    stmt = SLP_TREE_SCALAR_STMTS (node)[0];
    stmt_info = vinfo_for_stmt (stmt);
--- 3031,3043 ----
    tree vectype;
    int i;
    slp_tree loads_node;
!   slp_tree child;
  
    if (!node)
      return false;
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     vect_schedule_slp_instance (child, instance, vectorization_factor);
  
    stmt = SLP_TREE_SCALAR_STMTS (node)[0];
    stmt_info = vinfo_for_stmt (stmt);
*************** vect_remove_slp_scalar_calls (slp_tree n
*** 3111,3117 ****
    gimple stmt, new_stmt;
    gimple_stmt_iterator gsi;
    int i;
!   slp_void_p child;
    tree lhs;
    stmt_vec_info stmt_info;
  
--- 3127,3133 ----
    gimple stmt, new_stmt;
    gimple_stmt_iterator gsi;
    int i;
!   slp_tree child;
    tree lhs;
    stmt_vec_info stmt_info;
  
*************** vect_remove_slp_scalar_calls (slp_tree n
*** 3119,3125 ****
      return;
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     vect_remove_slp_scalar_calls ((slp_tree) child);
  
    FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), i, stmt)
      {
--- 3135,3141 ----
      return;
  
    FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
!     vect_remove_slp_scalar_calls (child);
  
    FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), i, stmt)
      {
Index: gcc/tree-vectorizer.h
===================================================================
*** gcc/tree-vectorizer.h       (revision 197621)
--- gcc/tree-vectorizer.h       (working copy)
*************** add_stmt_info_to_vec (stmt_vector_for_co
*** 97,109 ****
  /************************************************************************
    SLP
   ************************************************************************/
! typedef void *slp_void_p;
  
  /* A computation tree of an SLP instance.  Each node corresponds to a group of
     stmts to be packed in a SIMD stmt.  */
! typedef struct _slp_tree {
    /* Nodes that contain def-stmts of this node statements operands.  */
!   vec<slp_void_p> children;
    /* A group of scalar stmts to be vectorized together.  */
    vec<gimple> stmts;
    /* Vectorized stmt/s.  */
--- 97,109 ----
  /************************************************************************
    SLP
   ************************************************************************/
! typedef struct _slp_tree *slp_tree;
  
  /* A computation tree of an SLP instance.  Each node corresponds to a group of
     stmts to be packed in a SIMD stmt.  */
! struct _slp_tree {
    /* Nodes that contain def-stmts of this node statements operands.  */
!   vec<slp_tree> children;
    /* A group of scalar stmts to be vectorized together.  */
    vec<gimple> stmts;
    /* Vectorized stmt/s.  */
*************** typedef struct _slp_tree {
*** 113,119 ****
       scalar elements in one scalar iteration (GROUP_SIZE) multiplied by VF
       divided by vector size.  */
    unsigned int vec_stmts_size;
! } *slp_tree;
  
  
  /* SLP instance is a sequence of stmts in a loop that can be packed into
--- 113,119 ----
       scalar elements in one scalar iteration (GROUP_SIZE) multiplied by VF
       divided by vector size.  */
    unsigned int vec_stmts_size;
! };
  
  
  /* SLP instance is a sequence of stmts in a loop that can be packed into
*************** extern tree vect_setup_realignment (gimp
*** 941,947 ****
  extern void vect_transform_grouped_load (gimple, vec<tree> , int,
                                           gimple_stmt_iterator *);
  extern void vect_record_grouped_load_vectors (gimple, vec<tree> );
- extern int vect_get_place_in_interleaving_chain (gimple, gimple);
  extern tree vect_get_new_vect_var (tree, enum vect_var_kind, const char *);
  extern tree vect_create_addr_base_for_vector_ref (gimple, gimple_seq *,
                                                    tree, struct loop *);
--- 941,946 ----

Reply via email to