tree-vect-loop.c (get_initial_def_for_induction): Use build_constructor directly.
authorRichard Guenther <rguenther@suse.de>
Fri, 16 Mar 2012 09:54:36 +0000 (09:54 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 16 Mar 2012 09:54:36 +0000 (09:54 +0000)
2012-03-16  Richard Guenther  <rguenther@suse.de>

* tree-vect-loop.c (get_initial_def_for_induction): Use
build_constructor directly.
* tree-vect-stmts.c (vect_get_vec_def_for_operand): Use
build_vector_from_val.
* tree.c (build_vector_from_val): Avoid creating a constructor
first when we want a constant vector.

From-SVN: r185461

gcc/ChangeLog
gcc/tree-vect-loop.c
gcc/tree-vect-stmts.c
gcc/tree.c

index fec9c36..4fef9b1 100644 (file)
@@ -1,3 +1,12 @@
+2012-03-16  Richard Guenther  <rguenther@suse.de>
+
+       * tree-vect-loop.c (get_initial_def_for_induction): Use
+       build_constructor directly.
+       * tree-vect-stmts.c (vect_get_vec_def_for_operand): Use
+       build_vector_from_val.
+       * tree.c (build_vector_from_val): Avoid creating a constructor
+       first when we want a constant vector.
+
 2012-03-16  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * doc/install.texi (Specific, *-*-solaris2*): Improve wording.
index abba2b9..abf131e 100644 (file)
@@ -3041,6 +3041,8 @@ get_initial_def_for_induction (gimple iv_phi)
     }
   else
     {
+      VEC(constructor_elt,gc) *v;
+
       /* 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 (scalar_type, vect_scalar_var, "var_");
@@ -3053,8 +3055,8 @@ get_initial_def_for_induction (gimple iv_phi)
          gcc_assert (!new_bb);
        }
 
-      t = NULL_TREE;
-      t = tree_cons (NULL_TREE, new_name, t);
+      v = VEC_alloc (constructor_elt, gc, nunits);
+      CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, new_name);
       for (i = 1; i < nunits; i++)
        {
          /* Create: new_name_i = new_name + step_expr  */
@@ -3073,10 +3075,10 @@ get_initial_def_for_induction (gimple iv_phi)
              fprintf (vect_dump, "created new init_stmt: ");
              print_gimple_stmt (vect_dump, init_stmt, 0, TDF_SLIM);
            }
-         t = tree_cons (NULL_TREE, new_name, t);
+         CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, new_name);
        }
       /* Create a vector from [new_name_0, new_name_1, ..., new_name_nunits-1]  */
-      vec = build_constructor_from_list (vectype, nreverse (t));
+      vec = build_constructor (vectype, v);
       vec_init = vect_init_vector (iv_phi, vec, vectype, NULL);
     }
 
index 13859af..8a1c678 100644 (file)
@@ -1227,9 +1227,7 @@ vect_get_vec_def_for_operand (tree op, gimple stmt, tree *scalar_def)
   loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_vinfo);
   tree vec_inv;
   tree vec_cst;
-  tree t = NULL_TREE;
   tree def;
-  int i;
   enum vect_def_type dt;
   bool is_simple_use;
   tree vector_type;
@@ -1284,7 +1282,6 @@ vect_get_vec_def_for_operand (tree op, gimple stmt, tree *scalar_def)
       {
        vector_type = get_vectype_for_scalar_type (TREE_TYPE (def));
        gcc_assert (vector_type);
-       nunits = TYPE_VECTOR_SUBPARTS (vector_type);
 
        if (scalar_def)
          *scalar_def = def;
@@ -1293,13 +1290,7 @@ vect_get_vec_def_for_operand (tree op, gimple stmt, tree *scalar_def)
         if (vect_print_dump_info (REPORT_DETAILS))
           fprintf (vect_dump, "Create vector_inv.");
 
-        for (i = nunits - 1; i >= 0; --i)
-          {
-            t = tree_cons (NULL_TREE, def, t);
-          }
-
-       /* FIXME: use build_constructor directly.  */
-        vec_inv = build_constructor_from_list (vector_type, t);
+       vec_inv = build_vector_from_val (vector_type, def);
         return vect_init_vector (stmt, vec_inv, vector_type, NULL);
       }
 
index 1734fc5..cfea9f7 100644 (file)
@@ -1372,7 +1372,6 @@ tree
 build_vector_from_val (tree vectype, tree sc) 
 {
   int i, nunits = TYPE_VECTOR_SUBPARTS (vectype);
-  VEC(constructor_elt, gc) *v = NULL;
 
   if (sc == error_mark_node)
     return sc;
@@ -1386,14 +1385,20 @@ build_vector_from_val (tree vectype, tree sc)
   gcc_checking_assert (types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (sc)),
                                           TREE_TYPE (vectype)));
 
-  v = VEC_alloc (constructor_elt, gc, nunits);
-  for (i = 0; i < nunits; ++i)
-    CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, sc);
-
   if (CONSTANT_CLASS_P (sc))
-    return build_vector_from_ctor (vectype, v);
-  else 
-    return build_constructor (vectype, v);
+    {
+      tree *v = XALLOCAVEC (tree, nunits);
+      for (i = 0; i < nunits; ++i)
+       v[i] = sc;
+      return build_vector (vectype, v);
+    }
+  else
+    {
+      VEC(constructor_elt, gc) *v = VEC_alloc (constructor_elt, gc, nunits);
+      for (i = 0; i < nunits; ++i)
+       CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, sc);
+      return build_constructor (vectype, v);
+    }
 }
 
 /* Return a new CONSTRUCTOR node whose type is TYPE and whose values