tree-vectorizer.h (vect_get_new_ssa_name): Declare.
authorRichard Biener <rguenther@suse.de>
Thu, 15 Oct 2015 11:39:09 +0000 (11:39 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 15 Oct 2015 11:39:09 +0000 (11:39 +0000)
2015-10-15  Richard Biener  <rguenther@suse.de>

* tree-vectorizer.h (vect_get_new_ssa_name): Declare.
* tree-vect-data-refs.c (vect_get_new_ssa_name): New helper.
* tree-vect-loop.c (get_initial_def_for_induction): Drop
use of force_gimple_operand in favor of gimple_build.
Use vect_get_new_ssa_name.
* tree-vect-stmts.c (vect_init_vector): Use vect_get_new_ssa_name.
(vectorizable_mask_load_store): Likewise.
(vectorizable_call): Likewise.
(vectorizable_store): Likewise.
(vectorizable_load): Likewise.
(vect_get_vec_def_for_stmt_copy): Remove redundant stmt.

From-SVN: r228841

gcc/ChangeLog
gcc/tree-vect-data-refs.c
gcc/tree-vect-loop.c
gcc/tree-vect-stmts.c
gcc/tree-vectorizer.h

index 75c4c17dd35d9751f1366fb2726bc76de5e773ec..9e153a84e879c8a0eb6f6f8a694aba8b2eeb3493 100644 (file)
@@ -1,3 +1,17 @@
+2015-10-15  Richard Biener  <rguenther@suse.de>
+
+       * tree-vectorizer.h (vect_get_new_ssa_name): Declare.
+       * tree-vect-data-refs.c (vect_get_new_ssa_name): New helper.
+       * tree-vect-loop.c (get_initial_def_for_induction): Drop
+       use of force_gimple_operand in favor of gimple_build.
+       Use vect_get_new_ssa_name.
+       * tree-vect-stmts.c (vect_init_vector): Use vect_get_new_ssa_name.
+       (vectorizable_mask_load_store): Likewise.
+       (vectorizable_call): Likewise.
+       (vectorizable_store): Likewise.
+       (vectorizable_load): Likewise.
+       (vect_get_vec_def_for_stmt_copy): Remove redundant stmt.
+
 2015-10-15  Richard Sandiford  <richard.sandiford@arm.com>
 
        PR tree-optimization/67945
index c3db22fa87f435bd90c5e7d845b2fbf2f0ec0505..755b5a17e50d79c47980dbb7387e1261606048d8 100644 (file)
@@ -3897,6 +3897,41 @@ vect_get_new_vect_var (tree type, enum vect_var_kind var_kind, const char *name)
   return new_vect_var;
 }
 
+/* Like vect_get_new_vect_var but return an SSA name.  */
+
+tree
+vect_get_new_ssa_name (tree type, enum vect_var_kind var_kind, const char *name)
+{
+  const char *prefix;
+  tree new_vect_var;
+
+  switch (var_kind)
+  {
+  case vect_simple_var:
+    prefix = "vect";
+    break;
+  case vect_scalar_var:
+    prefix = "stmp";
+    break;
+  case vect_pointer_var:
+    prefix = "vectp";
+    break;
+  default:
+    gcc_unreachable ();
+  }
+
+  if (name)
+    {
+      char* tmp = concat (prefix, "_", name, NULL);
+      new_vect_var = make_temp_ssa_name (type, NULL, tmp);
+      free (tmp);
+    }
+  else
+    new_vect_var = make_temp_ssa_name (type, NULL, prefix);
+
+  return new_vect_var;
+}
+
 /* Duplicate ptr info and set alignment/misaligment on NAME from DR.  */
 
 static void
index 9285e516b46afd0d54a8e54a22617e3c1c5c0f96..32c54a78d88e88a04985725e9114b38e5b04902b 100644 (file)
@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-scalar-evolution.h"
 #include "tree-vectorizer.h"
 #include "target.h"
+#include "gimple-fold.h"
 
 /* Loop Vectorization Pass.
 
@@ -3341,9 +3342,8 @@ get_initial_def_for_induction (gimple *iv_phi)
   struct loop *iv_loop;
   basic_block new_bb;
   tree new_vec, vec_init, vec_step, t;
-  tree new_var;
   tree new_name;
-  gimple *init_stmt, *new_stmt;
+  gimple *new_stmt;
   gphi *induction_phi;
   tree induc_def, vec_def, vec_dest;
   tree init_expr, step_expr;
@@ -3353,7 +3353,7 @@ get_initial_def_for_induction (gimple *iv_phi)
   tree expr;
   stmt_vec_info phi_info = vinfo_for_stmt (iv_phi);
   bool nested_in_vect_loop = false;
-  gimple_seq stmts = NULL;
+  gimple_seq stmts;
   imm_use_iterator imm_iter;
   use_operand_p use_p;
   gimple *exit_phi;
@@ -3394,9 +3394,8 @@ get_initial_def_for_induction (gimple *iv_phi)
   gcc_assert (ncopies >= 1);
 
   /* Convert the step to the desired type.  */
-  step_expr = force_gimple_operand (fold_convert (TREE_TYPE (vectype),
-                                                 step_expr),
-                                   &stmts, true, NULL_TREE);
+  stmts = NULL;
+  step_expr = gimple_convert (&stmts, TREE_TYPE (vectype), step_expr);
   if (stmts)
     {
       new_bb = gsi_insert_seq_on_edge_immediate (pe, stmts);
@@ -3417,14 +3416,13 @@ get_initial_def_for_induction (gimple *iv_phi)
       if (!useless_type_conversion_p (vectype, TREE_TYPE (vec_init)))
        {
          new_stmt
-           = gimple_build_assign (vect_get_new_vect_var (vectype,
+           = gimple_build_assign (vect_get_new_ssa_name (vectype,
                                                          vect_simple_var,
                                                          "vec_iv_"),
                                   VIEW_CONVERT_EXPR,
                                   build1 (VIEW_CONVERT_EXPR, vectype,
                                           vec_init));
-         vec_init = make_ssa_name (gimple_assign_lhs (new_stmt), new_stmt);
-         gimple_assign_set_lhs (new_stmt, vec_init);
+         vec_init = gimple_assign_lhs (new_stmt);
          new_bb = gsi_insert_on_edge_immediate (loop_preheader_edge (iv_loop),
                                                 new_stmt);
          gcc_assert (!new_bb);
@@ -3438,16 +3436,8 @@ get_initial_def_for_induction (gimple *iv_phi)
 
       /* iv_loop is the loop to be vectorized. Create:
         vec_init = [X, X+S, X+2*S, X+3*S] (S = step_expr, X = init_expr)  */
-      new_var = vect_get_new_vect_var (TREE_TYPE (vectype),
-                                      vect_scalar_var, "var_");
-      new_name = force_gimple_operand (fold_convert (TREE_TYPE (vectype),
-                                                    init_expr),
-                                      &stmts, false, new_var);
-      if (stmts)
-       {
-         new_bb = gsi_insert_seq_on_edge_immediate (pe, stmts);
-         gcc_assert (!new_bb);
-       }
+      stmts = NULL;
+      new_name = gimple_convert (&stmts, TREE_TYPE (vectype), init_expr);
 
       vec_alloc (v, nunits);
       bool constant_p = is_gimple_min_invariant (new_name);
@@ -3455,26 +3445,18 @@ get_initial_def_for_induction (gimple *iv_phi)
       for (i = 1; i < nunits; i++)
        {
          /* Create: new_name_i = new_name + step_expr  */
-         new_name = fold_build2 (PLUS_EXPR, TREE_TYPE (new_name),
-                                 new_name, step_expr);
+         new_name = gimple_build (&stmts, PLUS_EXPR, TREE_TYPE (new_name),
+                                  new_name, step_expr);
          if (!is_gimple_min_invariant (new_name))
-           {
-             init_stmt = gimple_build_assign (new_var, new_name);
-             new_name = make_ssa_name (new_var, init_stmt);
-             gimple_assign_set_lhs (init_stmt, new_name);
-             new_bb = gsi_insert_on_edge_immediate (pe, init_stmt);
-             gcc_assert (!new_bb);
-             if (dump_enabled_p ())
-               {
-                 dump_printf_loc (MSG_NOTE, vect_location,
-                                  "created new init_stmt: ");
-                 dump_gimple_stmt (MSG_NOTE, TDF_SLIM, init_stmt, 0);
-                  dump_printf (MSG_NOTE, "\n");
-               }
-             constant_p = false;
-           }
+           constant_p = false;
          CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, new_name);
        }
+      if (stmts)
+       {
+         new_bb = gsi_insert_seq_on_edge_immediate (pe, stmts);
+         gcc_assert (!new_bb);
+       }
+
       /* Create a vector from [new_name_0, new_name_1, ..., new_name_nunits-1]  */
       if (constant_p)
        new_vec = build_vector_from_ctor (vectype, v);
index 4f5895c195babe02ed58acc4bee5ce03c7c6dd02..1386dc05549bfa39acf0f1c2c11d6f89895e8dd1 100644 (file)
@@ -1319,13 +1319,10 @@ vect_init_vector (gimple *stmt, tree val, tree type, gimple_stmt_iterator *gsi)
       val = build_vector_from_val (type, val);
     }
 
-  new_var = vect_get_new_vect_var (type, vect_simple_var, "cst_");
-  init_stmt = gimple_build_assign  (new_var, val);
-  new_temp = make_ssa_name (new_var, init_stmt);
-  gimple_assign_set_lhs (init_stmt, new_temp);
+  new_temp = vect_get_new_ssa_name (type, vect_simple_var, "cst_");
+  init_stmt = gimple_build_assign  (new_temp, val);
   vect_init_vector_1 (stmt, init_stmt, gsi);
-  vec_oprnd = gimple_assign_lhs (init_stmt);
-  return vec_oprnd;
+  return new_temp;
 }
 
 
@@ -1509,7 +1506,6 @@ vect_get_vec_def_for_stmt_copy (enum vect_def_type dt, tree vec_oprnd)
   gcc_assert (def_stmt_info);
   vec_stmt_for_operand = STMT_VINFO_RELATED_STMT (def_stmt_info);
   gcc_assert (vec_stmt_for_operand);
-  vec_oprnd = gimple_get_lhs (vec_stmt_for_operand);
   if (gimple_code (vec_stmt_for_operand) == GIMPLE_PHI)
     vec_oprnd = PHI_RESULT (vec_stmt_for_operand);
   else
@@ -1888,8 +1884,7 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi,
            {
              gcc_assert (TYPE_VECTOR_SUBPARTS (TREE_TYPE (op))
                          == TYPE_VECTOR_SUBPARTS (idxtype));
-             var = vect_get_new_vect_var (idxtype, vect_simple_var, NULL);
-             var = make_ssa_name (var);
+             var = vect_get_new_ssa_name (idxtype, vect_simple_var);
              op = build1 (VIEW_CONVERT_EXPR, idxtype, op);
              new_stmt
                = gimple_build_assign (var, VIEW_CONVERT_EXPR, op);
@@ -1915,9 +1910,7 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi,
                {
                  gcc_assert (TYPE_VECTOR_SUBPARTS (TREE_TYPE (mask_op))
                              == TYPE_VECTOR_SUBPARTS (masktype));
-                 var = vect_get_new_vect_var (masktype, vect_simple_var,
-                                              NULL);
-                 var = make_ssa_name (var);
+                 var = vect_get_new_ssa_name (masktype, vect_simple_var);
                  mask_op = build1 (VIEW_CONVERT_EXPR, masktype, mask_op);
                  new_stmt
                    = gimple_build_assign (var, VIEW_CONVERT_EXPR, mask_op);
@@ -1934,8 +1927,7 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi,
            {
              gcc_assert (TYPE_VECTOR_SUBPARTS (vectype)
                          == TYPE_VECTOR_SUBPARTS (rettype));
-             var = vect_get_new_vect_var (rettype, vect_simple_var, NULL);
-             op = make_ssa_name (var, new_stmt);
+             op = vect_get_new_ssa_name (rettype, vect_simple_var);
              gimple_call_set_lhs (new_stmt, op);
              vect_finish_stmt_generation (stmt, new_stmt, gsi);
              var = make_ssa_name (vec_dest);
@@ -2379,14 +2371,11 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
                v[k] = build_int_cst (unsigned_type_node, j * nunits_out + k);
              tree cst = build_vector (vectype_out, v);
              tree new_var
-               = vect_get_new_vect_var (vectype_out, vect_simple_var, "cst_");
+               = vect_get_new_ssa_name (vectype_out, vect_simple_var, "cst_");
              gimple *init_stmt = gimple_build_assign (new_var, cst);
-             new_temp = make_ssa_name (new_var, init_stmt);
-             gimple_assign_set_lhs (init_stmt, new_temp);
              vect_init_vector_1 (stmt, init_stmt, NULL);
              new_temp = make_ssa_name (vec_dest);
-             new_stmt = gimple_build_assign (new_temp,
-                                             gimple_assign_lhs (init_stmt));
+             new_stmt = gimple_build_assign (new_temp, new_var);
            }
          else
            {
@@ -5350,8 +5339,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
            {
              gcc_assert (TYPE_VECTOR_SUBPARTS (TREE_TYPE (src))
                          == TYPE_VECTOR_SUBPARTS (srctype));
-             var = vect_get_new_vect_var (srctype, vect_simple_var, NULL);
-             var = make_ssa_name (var);
+             var = vect_get_new_ssa_name (srctype, vect_simple_var);
              src = build1 (VIEW_CONVERT_EXPR, srctype, src);
              new_stmt = gimple_build_assign (var, VIEW_CONVERT_EXPR, src);
              vect_finish_stmt_generation (stmt, new_stmt, gsi);
@@ -5362,8 +5350,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
            {
              gcc_assert (TYPE_VECTOR_SUBPARTS (TREE_TYPE (op))
                          == TYPE_VECTOR_SUBPARTS (idxtype));
-             var = vect_get_new_vect_var (idxtype, vect_simple_var, NULL);
-             var = make_ssa_name (var);
+             var = vect_get_new_ssa_name (idxtype, vect_simple_var);
              op = build1 (VIEW_CONVERT_EXPR, idxtype, op);
              new_stmt = gimple_build_assign (var, VIEW_CONVERT_EXPR, op);
              vect_finish_stmt_generation (stmt, new_stmt, gsi);
@@ -6408,8 +6395,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
            {
              gcc_assert (TYPE_VECTOR_SUBPARTS (TREE_TYPE (op))
                          == TYPE_VECTOR_SUBPARTS (idxtype));
-             var = vect_get_new_vect_var (idxtype, vect_simple_var, NULL);
-             var = make_ssa_name (var);
+             var = vect_get_new_ssa_name (idxtype, vect_simple_var);
              op = build1 (VIEW_CONVERT_EXPR, idxtype, op);
              new_stmt
                = gimple_build_assign (var, VIEW_CONVERT_EXPR, op);
@@ -6424,8 +6410,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
            {
              gcc_assert (TYPE_VECTOR_SUBPARTS (vectype)
                          == TYPE_VECTOR_SUBPARTS (rettype));
-             var = vect_get_new_vect_var (rettype, vect_simple_var, NULL);
-             op = make_ssa_name (var, new_stmt);
+             op = vect_get_new_ssa_name (rettype, vect_simple_var);
              gimple_call_set_lhs (new_stmt, op);
              vect_finish_stmt_generation (stmt, new_stmt, gsi);
              var = make_ssa_name (vec_dest);
index aca3ccc286a5f3d7ff34b7b13ac7b32103e542d7..bdd8e6aec328a228ed94e2b9d72ef8dd82ab7988 100644 (file)
@@ -1020,6 +1020,8 @@ extern void vect_transform_grouped_load (gimple *, vec<tree> , int,
                                          gimple_stmt_iterator *);
 extern void vect_record_grouped_load_vectors (gimple *, vec<tree> );
 extern tree vect_get_new_vect_var (tree, enum vect_var_kind, const char *);
+extern tree vect_get_new_ssa_name (tree, enum vect_var_kind,
+                                  const char * = NULL);
 extern tree vect_create_addr_base_for_vector_ref (gimple *, gimple_seq *,
                                                  tree, struct loop *,
                                                  tree = NULL_TREE);