Commit 5467ee52 by Richard Guenther Committed by Richard Biener

re PR tree-optimization/52721 (segfault in vect_init_vector)

2012-03-26  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/52721
	* tree-vect-stmts.c (vect_init_vector): Handle scalars.

From-SVN: r185799
parent 39f3fed6
2012-03-26 Richard Guenther <rguenther@suse.de>
PR tree-optimization/52721
* tree-vect-stmts.c (vect_init_vector): Handle scalars.
2012-03-26 Ulrich Weigand <ulrich.weigand@linaro.org> 2012-03-26 Ulrich Weigand <ulrich.weigand@linaro.org>
PR tree-optimization/52686 PR tree-optimization/52686
......
...@@ -1142,7 +1142,6 @@ vect_get_load_cost (struct data_reference *dr, int ncopies, ...@@ -1142,7 +1142,6 @@ vect_get_load_cost (struct data_reference *dr, int ncopies,
static void static void
vect_init_vector_1 (gimple stmt, gimple new_stmt, gimple_stmt_iterator *gsi) vect_init_vector_1 (gimple stmt, gimple new_stmt, gimple_stmt_iterator *gsi)
{ {
if (gsi) if (gsi)
vect_finish_stmt_generation (stmt, new_stmt, gsi); vect_finish_stmt_generation (stmt, new_stmt, gsi);
else else
...@@ -1185,48 +1184,48 @@ vect_init_vector_1 (gimple stmt, gimple new_stmt, gimple_stmt_iterator *gsi) ...@@ -1185,48 +1184,48 @@ vect_init_vector_1 (gimple stmt, gimple new_stmt, gimple_stmt_iterator *gsi)
/* Function vect_init_vector. /* Function vect_init_vector.
Insert a new stmt (INIT_STMT) that initializes a new vector variable with Insert a new stmt (INIT_STMT) that initializes a new variable of type
the vector elements of VECTOR_VAR. Place the initialization at BSI if it TYPE with the value VAL. If TYPE is a vector type and VAL does not have
is not NULL. Otherwise, place the initialization at the loop preheader. vector type a vector with all elements equal to VAL is created first.
Place the initialization at BSI if it is not NULL. Otherwise, place the
initialization at the loop preheader.
Return the DEF of INIT_STMT. Return the DEF of INIT_STMT.
It will be used in the vectorization of STMT. */ It will be used in the vectorization of STMT. */
tree tree
vect_init_vector (gimple stmt, tree vector_var, tree vector_type, vect_init_vector (gimple stmt, tree val, tree type, gimple_stmt_iterator *gsi)
gimple_stmt_iterator *gsi)
{ {
tree new_var; tree new_var;
gimple init_stmt; gimple init_stmt;
tree vec_oprnd; tree vec_oprnd;
tree new_temp; tree new_temp;
if (TREE_CODE (TREE_TYPE (vector_var)) != VECTOR_TYPE) if (TREE_CODE (type) == VECTOR_TYPE
&& TREE_CODE (TREE_TYPE (val)) != VECTOR_TYPE)
{ {
if (!types_compatible_p (TREE_TYPE (vector_type), if (!types_compatible_p (TREE_TYPE (type), TREE_TYPE (val)))
TREE_TYPE (vector_var)))
{ {
if (CONSTANT_CLASS_P (vector_var)) if (CONSTANT_CLASS_P (val))
vector_var = fold_unary (VIEW_CONVERT_EXPR, TREE_TYPE (vector_type), val = fold_unary (VIEW_CONVERT_EXPR, TREE_TYPE (type), val);
vector_var);
else else
{ {
new_var = create_tmp_reg (TREE_TYPE (vector_type), NULL); new_var = create_tmp_reg (TREE_TYPE (type), NULL);
add_referenced_var (new_var); add_referenced_var (new_var);
init_stmt = gimple_build_assign_with_ops (NOP_EXPR, init_stmt = gimple_build_assign_with_ops (NOP_EXPR,
new_var, vector_var, new_var, val,
NULL_TREE); NULL_TREE);
new_temp = make_ssa_name (new_var, init_stmt); new_temp = make_ssa_name (new_var, init_stmt);
gimple_assign_set_lhs (init_stmt, new_temp); gimple_assign_set_lhs (init_stmt, new_temp);
vect_init_vector_1 (stmt, init_stmt, gsi); vect_init_vector_1 (stmt, init_stmt, gsi);
vector_var = new_temp; val = new_temp;
} }
} }
vector_var = build_vector_from_val (vector_type, vector_var); val = build_vector_from_val (type, val);
} }
new_var = vect_get_new_vect_var (vector_type, vect_simple_var, "cst_"); new_var = vect_get_new_vect_var (type, vect_simple_var, "cst_");
add_referenced_var (new_var); add_referenced_var (new_var);
init_stmt = gimple_build_assign (new_var, vector_var); init_stmt = gimple_build_assign (new_var, val);
new_temp = make_ssa_name (new_var, init_stmt); new_temp = make_ssa_name (new_var, init_stmt);
gimple_assign_set_lhs (init_stmt, new_temp); gimple_assign_set_lhs (init_stmt, new_temp);
vect_init_vector_1 (stmt, init_stmt, gsi); vect_init_vector_1 (stmt, init_stmt, gsi);
......
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