Commit 4ee279f2 by Dorit Nuzman Committed by Dorit Nuzman

re PR tree-optimization/37574 (ICE with the vectorizer and GC)

        PR tree-optimization/37574
        * tree-vectorizer.c (vect_is_simple_use): Fix indentation.
        * tree-vect-transform.c (vect_get_constant_vectors): Use vectype
        instead of vector_type for constants. Take computation out of loop.
        (vect_get_vec_def_for_operand): Use only vectype for constant case,
        and use only vector_type for invariant case.
        (get_initial_def_for_reduction): Use vectype instead of vector_type.

From-SVN: r140685
parent 105b7136
2008-09-26 Dorit Nuzman <dorit@il.ibm.com>
PR tree-optimization/37574
* tree-vectorizer.c (vect_is_simple_use): Fix indentation.
* tree-vect-transform.c (vect_get_constant_vectors): Use vectype
instead of vector_type for constants. Take computation out of loop.
(vect_get_vec_def_for_operand): Use only vectype for constant case,
and use only vector_type for invariant case.
(get_initial_def_for_reduction): Use vectype instead of vector_type.
2008-09-25 Jakub Jelinek <jakub@redhat.com> 2008-09-25 Jakub Jelinek <jakub@redhat.com>
PR c/37645 PR c/37645
......
2008-09-26 Dorit Nuzman <dorit@il.ibm.com>
PR tree-optimization/37574
* gcc.dg/vect/ggc-pr37574.c: New test.
* gcc.dg/vect/vect.exp: Compile some tests with ggc flags.
2008-09-25 Jakub Jelinek <jakub@redhat.com> 2008-09-25 Jakub Jelinek <jakub@redhat.com>
PR c/37645 PR c/37645
......
/* { dg-do compile } */
#include <stdarg.h>
unsigned short in[40 +128];
int main (void) {
int i = 0, j = 0;
unsigned int diff;
unsigned int s=0,sum=0;
for (i = 0; i < 40;i++)
{
diff = 0;
for (j = 0; j < 128;j+=8)
diff += in[j+i];
s += ((unsigned short)diff>>3);
}
if (s != sum)
return -1;
return 0;
}
...@@ -242,6 +242,12 @@ lappend DEFAULT_VECTCFLAGS "-Os" ...@@ -242,6 +242,12 @@ lappend DEFAULT_VECTCFLAGS "-Os"
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/Os-vect-*.\[cS\]]] \ dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/Os-vect-*.\[cS\]]] \
"" $DEFAULT_VECTCFLAGS "" $DEFAULT_VECTCFLAGS
# With --param ggc-min-expand=0 --param ggc-min-heapsize=0
set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
lappend DEFAULT_VECTCFLAGS "--param" "ggc-min-expand=0" "--param" "ggc-min-heapsize=0"
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/ggc-*.\[cS\]]] \
"" $DEFAULT_VECTCFLAGS
# With -O3 # With -O3
set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
lappend DEFAULT_VECTCFLAGS "-O3" lappend DEFAULT_VECTCFLAGS "-O3"
......
...@@ -1401,7 +1401,7 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds, ...@@ -1401,7 +1401,7 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds,
gimple stmt = VEC_index (gimple, stmts, 0); gimple stmt = VEC_index (gimple, stmts, 0);
stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt); stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt);
tree vectype = STMT_VINFO_VECTYPE (stmt_vinfo); tree vectype = STMT_VINFO_VECTYPE (stmt_vinfo);
int nunits = TYPE_VECTOR_SUBPARTS (vectype); int nunits;
tree vec_cst; tree vec_cst;
tree t = NULL_TREE; tree t = NULL_TREE;
int j, number_of_places_left_in_vector; int j, number_of_places_left_in_vector;
...@@ -1410,12 +1410,33 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds, ...@@ -1410,12 +1410,33 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds,
int group_size = VEC_length (gimple, stmts); int group_size = VEC_length (gimple, stmts);
unsigned int vec_num, i; unsigned int vec_num, i;
int number_of_copies = 1; int number_of_copies = 1;
bool is_store = false;
VEC (tree, heap) *voprnds = VEC_alloc (tree, heap, number_of_vectors); VEC (tree, heap) *voprnds = VEC_alloc (tree, heap, number_of_vectors);
bool constant_p; bool constant_p, is_store;
if (STMT_VINFO_DATA_REF (stmt_vinfo)) if (STMT_VINFO_DATA_REF (stmt_vinfo))
is_store = true; {
is_store = true;
op = gimple_assign_rhs1 (stmt);
}
else
{
is_store = false;
op = gimple_op (stmt, op_num + 1);
}
if (CONSTANT_CLASS_P (op))
{
vector_type = vectype;
constant_p = true;
}
else
{
vector_type = get_vectype_for_scalar_type (TREE_TYPE (op));
gcc_assert (vector_type);
constant_p = false;
}
nunits = TYPE_VECTOR_SUBPARTS (vector_type);
/* NUMBER_OF_COPIES is the number of times we need to use the same values in /* NUMBER_OF_COPIES is the number of times we need to use the same values in
created vectors. It is greater than 1 if unrolling is performed. created vectors. It is greater than 1 if unrolling is performed.
...@@ -1436,18 +1457,15 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds, ...@@ -1436,18 +1457,15 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds,
number_of_copies = least_common_multiple (nunits, group_size) / group_size; number_of_copies = least_common_multiple (nunits, group_size) / group_size;
number_of_places_left_in_vector = nunits; number_of_places_left_in_vector = nunits;
constant_p = true;
for (j = 0; j < number_of_copies; j++) for (j = 0; j < number_of_copies; j++)
{ {
for (i = group_size - 1; VEC_iterate (gimple, stmts, i, stmt); i--) for (i = group_size - 1; VEC_iterate (gimple, stmts, i, stmt); i--)
{ {
if (is_store) if (is_store)
op = gimple_assign_rhs1 (stmt); op = gimple_assign_rhs1 (stmt);
else else
op = gimple_op (stmt, op_num + 1); op = gimple_op (stmt, op_num + 1);
if (!CONSTANT_CLASS_P (op))
constant_p = false;
/* Create 'vect_ = {op0,op1,...,opn}'. */ /* Create 'vect_ = {op0,op1,...,opn}'. */
t = tree_cons (NULL_TREE, op, t); t = tree_cons (NULL_TREE, op, t);
...@@ -1457,16 +1475,12 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds, ...@@ -1457,16 +1475,12 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds,
{ {
number_of_places_left_in_vector = nunits; number_of_places_left_in_vector = nunits;
vector_type = get_vectype_for_scalar_type (TREE_TYPE (op));
gcc_assert (vector_type);
if (constant_p) if (constant_p)
vec_cst = build_vector (vector_type, t); vec_cst = build_vector (vector_type, t);
else else
vec_cst = build_constructor_from_list (vector_type, t); vec_cst = build_constructor_from_list (vector_type, t);
constant_p = true;
VEC_quick_push (tree, voprnds, VEC_quick_push (tree, voprnds,
vect_init_vector (stmt, vec_cst, vector_type, vect_init_vector (stmt, vec_cst, vector_type, NULL));
NULL));
t = NULL_TREE; t = NULL_TREE;
} }
} }
...@@ -1886,7 +1900,7 @@ vect_get_vec_def_for_operand (tree op, gimple stmt, tree *scalar_def) ...@@ -1886,7 +1900,7 @@ vect_get_vec_def_for_operand (tree op, gimple stmt, tree *scalar_def)
stmt_vec_info def_stmt_info = NULL; stmt_vec_info def_stmt_info = NULL;
stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt); stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt);
tree vectype = STMT_VINFO_VECTYPE (stmt_vinfo); tree vectype = STMT_VINFO_VECTYPE (stmt_vinfo);
int nunits = TYPE_VECTOR_SUBPARTS (vectype); unsigned int nunits = TYPE_VECTOR_SUBPARTS (vectype);
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;
...@@ -1935,16 +1949,17 @@ vect_get_vec_def_for_operand (tree op, gimple stmt, tree *scalar_def) ...@@ -1935,16 +1949,17 @@ vect_get_vec_def_for_operand (tree op, gimple stmt, tree *scalar_def)
{ {
t = tree_cons (NULL_TREE, op, t); t = tree_cons (NULL_TREE, op, t);
} }
vector_type = get_vectype_for_scalar_type (TREE_TYPE (op)); vec_cst = build_vector (vectype, t);
gcc_assert (vector_type); return vect_init_vector (stmt, vec_cst, vectype, NULL);
vec_cst = build_vector (vector_type, t);
return vect_init_vector (stmt, vec_cst, vector_type, NULL);
} }
/* Case 2: operand is defined outside the loop - loop invariant. */ /* Case 2: operand is defined outside the loop - loop invariant. */
case vect_invariant_def: case vect_invariant_def:
{ {
vector_type = get_vectype_for_scalar_type (TREE_TYPE (def));
gcc_assert (vector_type);
nunits = TYPE_VECTOR_SUBPARTS (vector_type);
if (scalar_def) if (scalar_def)
*scalar_def = def; *scalar_def = def;
...@@ -1958,8 +1973,6 @@ vect_get_vec_def_for_operand (tree op, gimple stmt, tree *scalar_def) ...@@ -1958,8 +1973,6 @@ vect_get_vec_def_for_operand (tree op, gimple stmt, tree *scalar_def)
} }
/* FIXME: use build_constructor directly. */ /* FIXME: use build_constructor directly. */
vector_type = get_vectype_for_scalar_type (TREE_TYPE (def));
gcc_assert (vector_type);
vec_inv = build_constructor_from_list (vector_type, t); 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);
} }
...@@ -2222,6 +2235,7 @@ get_initial_def_for_reduction (gimple stmt, tree init_val, tree *adjustment_def) ...@@ -2222,6 +2235,7 @@ get_initial_def_for_reduction (gimple stmt, tree init_val, tree *adjustment_def)
struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo); struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
tree vectype = STMT_VINFO_VECTYPE (stmt_vinfo); tree vectype = STMT_VINFO_VECTYPE (stmt_vinfo);
int nunits = TYPE_VECTOR_SUBPARTS (vectype); int nunits = TYPE_VECTOR_SUBPARTS (vectype);
tree scalar_type = TREE_TYPE (vectype);
enum tree_code code = gimple_assign_rhs_code (stmt); enum tree_code code = gimple_assign_rhs_code (stmt);
tree type = TREE_TYPE (init_val); tree type = TREE_TYPE (init_val);
tree vecdef; tree vecdef;
...@@ -2229,7 +2243,6 @@ get_initial_def_for_reduction (gimple stmt, tree init_val, tree *adjustment_def) ...@@ -2229,7 +2243,6 @@ get_initial_def_for_reduction (gimple stmt, tree init_val, tree *adjustment_def)
tree init_def; tree init_def;
tree t = NULL_TREE; tree t = NULL_TREE;
int i; int i;
tree vector_type;
bool nested_in_vect_loop = false; bool nested_in_vect_loop = false;
gcc_assert (POINTER_TYPE_P (type) || INTEGRAL_TYPE_P (type) || SCALAR_FLOAT_TYPE_P (type)); gcc_assert (POINTER_TYPE_P (type) || INTEGRAL_TYPE_P (type) || SCALAR_FLOAT_TYPE_P (type));
...@@ -2250,15 +2263,14 @@ get_initial_def_for_reduction (gimple stmt, tree init_val, tree *adjustment_def) ...@@ -2250,15 +2263,14 @@ get_initial_def_for_reduction (gimple stmt, tree init_val, tree *adjustment_def)
else else
*adjustment_def = init_val; *adjustment_def = init_val;
/* Create a vector of zeros for init_def. */ /* Create a vector of zeros for init_def. */
if (SCALAR_FLOAT_TYPE_P (type)) if (SCALAR_FLOAT_TYPE_P (scalar_type))
def_for_init = build_real (type, dconst0); def_for_init = build_real (scalar_type, dconst0);
else else
def_for_init = build_int_cst (type, 0); def_for_init = build_int_cst (scalar_type, 0);
for (i = nunits - 1; i >= 0; --i) for (i = nunits - 1; i >= 0; --i)
t = tree_cons (NULL_TREE, def_for_init, t); t = tree_cons (NULL_TREE, def_for_init, t);
vector_type = get_vectype_for_scalar_type (TREE_TYPE (def_for_init)); init_def = build_vector (vectype, t);
gcc_assert (vector_type);
init_def = build_vector (vector_type, t);
break; break;
case MIN_EXPR: case MIN_EXPR:
...@@ -6008,7 +6020,6 @@ vect_create_mask_and_perm (gimple stmt, gimple next_scalar_stmt, ...@@ -6008,7 +6020,6 @@ vect_create_mask_and_perm (gimple stmt, gimple next_scalar_stmt,
for (i = mask_nunits - 1; i >= 0; --i) for (i = mask_nunits - 1; i >= 0; --i)
t = tree_cons (NULL_TREE, build_int_cst (mask_element_type, mask_array[i]), t = tree_cons (NULL_TREE, build_int_cst (mask_element_type, mask_array[i]),
t); t);
mask_vec = build_vector (mask_type, t); mask_vec = build_vector (mask_type, t);
mask = vect_init_vector (stmt, mask_vec, mask_type, NULL); mask = vect_init_vector (stmt, mask_vec, mask_type, NULL);
......
...@@ -2036,11 +2036,11 @@ vect_is_simple_use (tree operand, loop_vec_info loop_vinfo, gimple *def_stmt, ...@@ -2036,11 +2036,11 @@ vect_is_simple_use (tree operand, loop_vec_info loop_vinfo, gimple *def_stmt,
return true; return true;
} }
if (is_gimple_min_invariant (operand)) if (is_gimple_min_invariant (operand))
{ {
*def = operand; *def = operand;
*dt = vect_invariant_def; *dt = vect_invariant_def;
return true; return true;
} }
if (TREE_CODE (operand) == PAREN_EXPR) if (TREE_CODE (operand) == PAREN_EXPR)
{ {
......
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