Commit 9dc3f7de by Ira Rosen Committed by Ira Rosen

re PR tree-optimization/46049 (ICE: in expand_widen_pattern_expr, at…

re PR tree-optimization/46049 (ICE: in expand_widen_pattern_expr, at optabs.c:522 with -ftree-vectorize)


	PR tree-optimization/46049
	PR tree-optimization/46052
	* tree-vectorizer.h (enum stmt_vec_info_type): Add new value for
	shift.
	(vect_get_slp_defs): Add arguments.
	* tree-vect-loop.c (vect_create_epilog_for_reduction): Pass scalar
	operands to vect_get_slp_defs.
	(vectorizable_reduction): Fix comment, pass scalar operands to
	vect_get_slp_defs.
	* tree-vect-stmts.c (vect_get_vec_def_for_operand): Use operand's
	type to determine number of units in the created vector.
	(vect_get_vec_defs): Pass scalar operands to vect_get_slp_defs.
	(vectorizable_conversion): Fix comment.
	(vectorizable_shift): New function.
	(vectorizable_operation): Move code that handles shifts to
	vectorizable_shift.
	(vectorizable_type_demotion): Fix comment, pass scalar operands to
	vect_get_slp_defs.
	(vectorizable_type_promotion, vectorizable_store): Likewise.
	(vectorizable_condition): Fix comment.
	(vect_analyze_stmt): Call vectorizable_shift.
	(vect_transform_stmt): Likewise.
	* tree-vect-slp.c (vect_get_constant_vectors): Add new argument.
	Use it as the operand to create vectors for, except reduction
	initial definition and store.  Use operands type.
	(vect_get_slp_defs): Add new arguments.  Pass them to
	vect_get_constant_vectors.

From-SVN: r165777
parent 027dbed8
2010-10-21 Ira Rosen <irar@il.ibm.com>
PR tree-optimization/46049
PR tree-optimization/46052
* tree-vectorizer.h (enum stmt_vec_info_type): Add new value for
shift.
(vect_get_slp_defs): Add arguments.
* tree-vect-loop.c (vect_create_epilog_for_reduction): Pass scalar
operands to vect_get_slp_defs.
(vectorizable_reduction): Fix comment, pass scalar operands to
vect_get_slp_defs.
* tree-vect-stmts.c (vect_get_vec_def_for_operand): Use operand's
type to determine number of units in the created vector.
(vect_get_vec_defs): Pass scalar operands to vect_get_slp_defs.
(vectorizable_conversion): Fix comment.
(vectorizable_shift): New function.
(vectorizable_operation): Move code that handles shifts to
vectorizable_shift.
(vectorizable_type_demotion): Fix comment, pass scalar operands to
vect_get_slp_defs.
(vectorizable_type_promotion, vectorizable_store): Likewise.
(vectorizable_condition): Fix comment.
(vect_analyze_stmt): Call vectorizable_shift.
(vect_transform_stmt): Likewise.
* tree-vect-slp.c (vect_get_constant_vectors): Add new argument.
Use it as the operand to create vectors for, except reduction
initial definition and store. Use operands type.
(vect_get_slp_defs): Add new arguments. Pass them to
vect_get_constant_vectors.
2010-10-21 Nathan Froyd <froydnj@codesourcery.com>
* basic-block.h (single_succ_edge): Use gcc_checking_assert.
2010-10-21 Ira Rosen <irar@il.ibm.com>
PR tree-optimization/46049
PR tree-optimization/46052
* gcc.dg/vect/pr46052.c: New test.
* gcc.dg/vect/pr46049.c: New test.
2010-10-21 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/46007
......
/* { dg-do compile } */
typedef __INT16_TYPE__ int16_t;
typedef __INT32_TYPE__ int32_t;
static inline int32_t bar (int16_t x, int16_t y)
{
return x * y;
}
void foo (int16_t i, int16_t *p, int16_t x)
{
while (i--)
{
*p = bar (*p, x) >> 15;
p++;
*p = bar (*p, x) >> 15;
p++;
}
}
/* { dg-final { cleanup-tree-dump "vect" } } */
/* { dg-do compile } */
int i;
int a[2];
static inline char bar (void)
{
return i ? i : 1;
}
void foo (int n)
{
while (n--)
{
a[0] ^= bar ();
a[1] ^= bar ();
}
}
static inline char bar1 (void)
{
}
void foo1 (int n)
{
while (n--)
{
a[0] ^= bar1 ();
a[1] ^= bar1 ();
}
}
/* { dg-final { cleanup-tree-dump "vect" } } */
......@@ -3193,7 +3193,8 @@ vect_create_epilog_for_reduction (VEC (tree, heap) *vect_defs, gimple stmt,
/* Get the loop-entry arguments. */
if (slp_node)
vect_get_slp_defs (slp_node, &vec_initial_defs, NULL, reduc_index);
vect_get_slp_defs (reduction_op, NULL_TREE, slp_node, &vec_initial_defs,
NULL, reduc_index);
else
{
vec_initial_defs = VEC_alloc (tree, heap, 1);
......@@ -3965,7 +3966,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_iterator *gsi,
gcc_assert (is_gimple_assign (stmt));
/* Flatten RHS */
/* Flatten RHS. */
switch (get_gimple_rhs_class (gimple_assign_rhs_code (stmt)))
{
case GIMPLE_SINGLE_RHS:
......@@ -4332,8 +4333,20 @@ vectorizable_reduction (gimple stmt, gimple_stmt_iterator *gsi,
/* Handle uses. */
if (j == 0)
{
tree op0, op1 = NULL_TREE;
op0 = ops[!reduc_index];
if (op_type == ternary_op)
{
if (reduc_index == 0)
op1 = ops[2];
else
op1 = ops[1];
}
if (slp_node)
vect_get_slp_defs (slp_node, &vec_oprnds0, &vec_oprnds1, -1);
vect_get_slp_defs (op0, op1, slp_node, &vec_oprnds0, &vec_oprnds1,
-1);
else
{
loop_vec_def0 = vect_get_vec_def_for_operand (ops[!reduc_index],
......@@ -4341,13 +4354,8 @@ vectorizable_reduction (gimple stmt, gimple_stmt_iterator *gsi,
VEC_quick_push (tree, vec_oprnds0, loop_vec_def0);
if (op_type == ternary_op)
{
if (reduc_index == 0)
loop_vec_def1 = vect_get_vec_def_for_operand (ops[2], stmt,
NULL);
else
loop_vec_def1 = vect_get_vec_def_for_operand (ops[1], stmt,
NULL);
loop_vec_def1 = vect_get_vec_def_for_operand (op1, stmt,
NULL);
VEC_quick_push (tree, vec_oprnds1, loop_vec_def1);
}
}
......
......@@ -1817,7 +1817,8 @@ vect_update_slp_costs_according_to_vf (loop_vec_info loop_vinfo)
it is -1. */
static void
vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds,
vect_get_constant_vectors (tree op, slp_tree slp_node,
VEC (tree, heap) **vec_oprnds,
unsigned int op_num, unsigned int number_of_vectors,
int reduc_index)
{
......@@ -1829,7 +1830,7 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds,
tree t = NULL_TREE;
int j, number_of_places_left_in_vector;
tree vector_type;
tree op, vop;
tree vop;
int group_size = VEC_length (gimple, stmts);
unsigned int vec_num, i;
int number_of_copies = 1;
......@@ -1847,7 +1848,7 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds,
}
op_num = reduc_index - 1;
op = gimple_op (stmt, op_num + 1);
op = gimple_op (stmt, reduc_index);
/* For additional copies (see the explanation of NUMBER_OF_COPIES below)
we need either neutral operands or the original operands. See
get_initial_def_for_reduction() for details. */
......@@ -1889,25 +1890,16 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds,
op = gimple_assign_rhs1 (stmt);
}
else
{
is_store = false;
op = gimple_op (stmt, op_num + 1);
}
is_store = false;
gcc_assert (op);
if (CONSTANT_CLASS_P (op))
constant_p = true;
else
constant_p = false;
/* For POINTER_PLUS_EXPR we use the type of the constant/invariant itself.
If OP is the first operand of POINTER_PLUS_EXPR, its type is the type of
the statement, so it's OK to use OP's type for both first and second
operands. */
if (code == POINTER_PLUS_EXPR)
vector_type = get_vectype_for_scalar_type (TREE_TYPE (op));
else
vector_type = STMT_VINFO_VECTYPE (stmt_vinfo);
vector_type = get_vectype_for_scalar_type (TREE_TYPE (op));
gcc_assert (vector_type);
nunits = TYPE_VECTOR_SUBPARTS (vector_type);
......@@ -2043,7 +2035,8 @@ vect_get_slp_vect_defs (slp_tree slp_node, VEC (tree,heap) **vec_oprnds)
the right node. This is used when the second operand must remain scalar. */
void
vect_get_slp_defs (slp_tree slp_node, VEC (tree,heap) **vec_oprnds0,
vect_get_slp_defs (tree op0, tree op1, slp_tree slp_node,
VEC (tree,heap) **vec_oprnds0,
VEC (tree,heap) **vec_oprnds1, int reduc_index)
{
gimple first_stmt;
......@@ -2083,7 +2076,7 @@ vect_get_slp_defs (slp_tree slp_node, VEC (tree,heap) **vec_oprnds0,
vect_get_slp_vect_defs (SLP_TREE_LEFT (slp_node), vec_oprnds0);
else
/* Build vectors from scalar defs. */
vect_get_constant_vectors (slp_node, vec_oprnds0, 0, number_of_vects,
vect_get_constant_vectors (op0, slp_node, vec_oprnds0, 0, number_of_vects,
reduc_index);
if (STMT_VINFO_DATA_REF (vinfo_for_stmt (first_stmt)))
......@@ -2113,7 +2106,8 @@ vect_get_slp_defs (slp_tree slp_node, VEC (tree,heap) **vec_oprnds0,
vect_get_slp_vect_defs (SLP_TREE_RIGHT (slp_node), vec_oprnds1);
else
/* Build vectors from scalar defs. */
vect_get_constant_vectors (slp_node, vec_oprnds1, 1, number_of_vects, -1);
vect_get_constant_vectors (op1, slp_node, vec_oprnds1, 1, number_of_vects,
-1);
}
......
......@@ -353,6 +353,7 @@ enum stmt_vec_info_type {
undef_vec_info_type = 0,
load_vec_info_type,
store_vec_info_type,
shift_vec_info_type,
op_vec_info_type,
call_vec_info_type,
assignment_vec_info_type,
......@@ -884,7 +885,7 @@ extern void vect_update_slp_costs_according_to_vf (loop_vec_info);
extern bool vect_analyze_slp (loop_vec_info, bb_vec_info);
extern void vect_make_slp_decision (loop_vec_info);
extern void vect_detect_hybrid_slp (loop_vec_info);
extern void vect_get_slp_defs (slp_tree, VEC (tree,heap) **,
extern void vect_get_slp_defs (tree, tree, slp_tree, VEC (tree,heap) **,
VEC (tree,heap) **, int);
extern LOC find_bb_location (basic_block);
extern bb_vec_info vect_slp_analyze_bb (basic_block);
......
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