Commit 50a763ab by Richard Guenther Committed by Richard Biener

tree-vect-loop.c (get_initial_def_for_induction): Use build_constructor directly.

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
parent 6a26a74d
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> 2012-03-16 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* doc/install.texi (Specific, *-*-solaris2*): Improve wording. * doc/install.texi (Specific, *-*-solaris2*): Improve wording.
......
...@@ -3041,6 +3041,8 @@ get_initial_def_for_induction (gimple iv_phi) ...@@ -3041,6 +3041,8 @@ get_initial_def_for_induction (gimple iv_phi)
} }
else else
{ {
VEC(constructor_elt,gc) *v;
/* iv_loop is the loop to be vectorized. Create: /* 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) */ 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_"); 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) ...@@ -3053,8 +3055,8 @@ get_initial_def_for_induction (gimple iv_phi)
gcc_assert (!new_bb); gcc_assert (!new_bb);
} }
t = NULL_TREE; v = VEC_alloc (constructor_elt, gc, nunits);
t = tree_cons (NULL_TREE, new_name, t); CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, new_name);
for (i = 1; i < nunits; i++) for (i = 1; i < nunits; i++)
{ {
/* Create: new_name_i = new_name + step_expr */ /* Create: new_name_i = new_name + step_expr */
...@@ -3073,10 +3075,10 @@ get_initial_def_for_induction (gimple iv_phi) ...@@ -3073,10 +3075,10 @@ get_initial_def_for_induction (gimple iv_phi)
fprintf (vect_dump, "created new init_stmt: "); fprintf (vect_dump, "created new init_stmt: ");
print_gimple_stmt (vect_dump, init_stmt, 0, TDF_SLIM); 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] */ /* 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); vec_init = vect_init_vector (iv_phi, vec, vectype, NULL);
} }
......
...@@ -1227,9 +1227,7 @@ vect_get_vec_def_for_operand (tree op, gimple stmt, tree *scalar_def) ...@@ -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); loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_vinfo);
tree vec_inv; tree vec_inv;
tree vec_cst; tree vec_cst;
tree t = NULL_TREE;
tree def; tree def;
int i;
enum vect_def_type dt; enum vect_def_type dt;
bool is_simple_use; bool is_simple_use;
tree vector_type; tree vector_type;
...@@ -1284,7 +1282,6 @@ vect_get_vec_def_for_operand (tree op, gimple stmt, tree *scalar_def) ...@@ -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)); vector_type = get_vectype_for_scalar_type (TREE_TYPE (def));
gcc_assert (vector_type); gcc_assert (vector_type);
nunits = TYPE_VECTOR_SUBPARTS (vector_type);
if (scalar_def) if (scalar_def)
*scalar_def = def; *scalar_def = def;
...@@ -1293,13 +1290,7 @@ vect_get_vec_def_for_operand (tree op, gimple stmt, tree *scalar_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)) if (vect_print_dump_info (REPORT_DETAILS))
fprintf (vect_dump, "Create vector_inv."); fprintf (vect_dump, "Create vector_inv.");
for (i = nunits - 1; i >= 0; --i) vec_inv = build_vector_from_val (vector_type, def);
{
t = tree_cons (NULL_TREE, def, t);
}
/* FIXME: use build_constructor directly. */
vec_inv = build_constructor_from_list (vector_type, t);
return vect_init_vector (stmt, vec_inv, vector_type, NULL); return vect_init_vector (stmt, vec_inv, vector_type, NULL);
} }
......
...@@ -1372,7 +1372,6 @@ tree ...@@ -1372,7 +1372,6 @@ tree
build_vector_from_val (tree vectype, tree sc) build_vector_from_val (tree vectype, tree sc)
{ {
int i, nunits = TYPE_VECTOR_SUBPARTS (vectype); int i, nunits = TYPE_VECTOR_SUBPARTS (vectype);
VEC(constructor_elt, gc) *v = NULL;
if (sc == error_mark_node) if (sc == error_mark_node)
return sc; return sc;
...@@ -1386,14 +1385,20 @@ build_vector_from_val (tree vectype, tree 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)), gcc_checking_assert (types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (sc)),
TREE_TYPE (vectype))); 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)) if (CONSTANT_CLASS_P (sc))
return build_vector_from_ctor (vectype, v); {
tree *v = XALLOCAVEC (tree, nunits);
for (i = 0; i < nunits; ++i)
v[i] = sc;
return build_vector (vectype, v);
}
else 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 build_constructor (vectype, v);
}
} }
/* Return a new CONSTRUCTOR node whose type is TYPE and whose values /* Return a new CONSTRUCTOR node whose type is TYPE and whose values
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment