add vect_get_slp_vect_def
authorRichard Biener <rguenther@suse.de>
Thu, 4 Jun 2020 12:59:16 +0000 (14:59 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 4 Jun 2020 14:01:55 +0000 (16:01 +0200)
This adds vect_get_slp_vect_def to get at a SLP nodes vectorized def,
abstracting away the details.  It also fixes one stray failure to
use SLP_TREE_REPRESENTATIVE.

2020-05-04  Richard Biener  <rguenther@suse.de>

* tree-vectorizer.h (vect_get_slp_vect_def): Declare.
* tree-vect-loop.c (vect_create_epilog_for_reduction): Use it.
* tree-vect-stmts.c (vect_transform_stmt): Likewise.
(vect_is_simple_use): Use SLP_TREE_REPRESENTATIVE.
* tree-vect-slp.c (vect_get_slp_vect_defs): Fold into single
use ...
(vect_get_slp_defs): ... here.
(vect_get_slp_vect_def): New function.

gcc/tree-vect-loop.c
gcc/tree-vect-slp.c
gcc/tree-vect-stmts.c
gcc/tree-vectorizer.h

index e3fbf9f..f2c52ae 100644 (file)
@@ -4719,7 +4719,7 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo,
   for (unsigned i = 0; i < vec_num; i++)
     {
       if (slp_node)
-       def = gimple_get_lhs (SLP_TREE_VEC_STMTS (slp_node)[i]->stmt);
+       def = vect_get_slp_vect_def (slp_node, i);
       else
        def = gimple_get_lhs (STMT_VINFO_VEC_STMT (rdef_info)->stmt);
       for (j = 0; j < ncopies; j++)
index 65c49f5..1d26c31 100644 (file)
@@ -3660,23 +3660,17 @@ vect_create_constant_vectors (vec_info *vinfo, slp_tree op_node)
       SLP_TREE_VEC_DEFS (op_node).quick_push (vop);
 }
 
+/* Get the Ith vectorized definition from SLP_NODE.  */
 
-/* Get vectorized definitions from SLP_NODE that contains corresponding
-   vectorized def-stmts.  */
-
-static void
-vect_get_slp_vect_defs (slp_tree slp_node, vec<tree> *vec_oprnds)
+tree
+vect_get_slp_vect_def (slp_tree slp_node, unsigned i)
 {
-  stmt_vec_info vec_def_stmt_info;
-  unsigned int i;
-
-  gcc_assert (SLP_TREE_VEC_STMTS (slp_node).exists ());
-
-  FOR_EACH_VEC_ELT (SLP_TREE_VEC_STMTS (slp_node), i, vec_def_stmt_info)
-    vec_oprnds->quick_push (gimple_get_lhs (vec_def_stmt_info->stmt));
+  if (SLP_TREE_VEC_STMTS (slp_node).exists ())
+    return gimple_get_lhs (SLP_TREE_VEC_STMTS (slp_node)[i]->stmt);
+  else
+    return SLP_TREE_VEC_DEFS (slp_node)[i];
 }
 
-
 /* Get N vectorized definitions for SLP_NODE.  */
 
 void
@@ -3696,7 +3690,12 @@ vect_get_slp_defs (vec_info *,
         node or we need to create them (for invariants and constants).  */
       vec_defs.create (SLP_TREE_NUMBER_OF_VEC_STMTS (child));
       if (SLP_TREE_DEF_TYPE (child) == vect_internal_def)
-       vect_get_slp_vect_defs (child, &vec_defs);
+       {
+         unsigned j;
+         stmt_vec_info vec_def_stmt_info;
+         FOR_EACH_VEC_ELT (SLP_TREE_VEC_STMTS (child), j, vec_def_stmt_info)
+           vec_defs.quick_push (gimple_get_lhs (vec_def_stmt_info->stmt));
+       }
       else
        vec_defs.splice (SLP_TREE_VEC_DEFS (child));
 
index 4df1d90..c0be6ef 100644 (file)
@@ -11385,7 +11385,7 @@ vect_transform_stmt (vec_info *vinfo,
                      == SLP_TREE_VEC_STMTS (slp_node).length ());
          for (unsigned i = 0; i < SLP_TREE_VEC_STMTS (phi_node).length (); ++i)
            add_phi_arg (as_a <gphi *> (SLP_TREE_VEC_STMTS (phi_node)[i]->stmt),
-                        gimple_get_lhs (SLP_TREE_VEC_STMTS (slp_node)[i]->stmt),
+                        vect_get_slp_vect_def (slp_node, i),
                         e, gimple_phi_arg_location (phi, e->dest_idx));
        }
     }
@@ -11850,7 +11850,7 @@ vect_is_simple_use (vec_info *vinfo, stmt_vec_info stmt, slp_tree slp_node,
       slp_tree child = SLP_TREE_CHILDREN (slp_node)[operand];
       *slp_def = child;
       if (SLP_TREE_DEF_TYPE (child) == vect_internal_def)
-       *op = gimple_get_lhs (SLP_TREE_SCALAR_STMTS (child)[0]->stmt);
+       *op = gimple_get_lhs (SLP_TREE_REPRESENTATIVE (child)->stmt);
       else
        {
          if (def_stmt_info_out)
index 1396da7..9bb82a5 100644 (file)
@@ -1753,6 +1753,7 @@ extern void vect_get_vec_defs_for_stmt_copy (vec_info *,
 extern tree vect_init_vector (vec_info *, stmt_vec_info, tree, tree,
                               gimple_stmt_iterator *);
 extern tree vect_get_vec_def_for_stmt_copy (vec_info *, tree);
+extern tree vect_get_slp_vect_def (slp_tree, unsigned);
 extern bool vect_transform_stmt (vec_info *, stmt_vec_info,
                                 gimple_stmt_iterator *,
                                 slp_tree, slp_instance);