+2015-05-22 Richard Biener <rguenther@suse.de>
+
+ * tree-vectorizer.h (struct _slp_oprnd_info): Add second_pattern
+ member.
+ * tree-vect-loop.c (vect_analyze_loop_operations): Look at
+ patterns when determining whether SLP is pure.
+ (vect_is_slp_reduction): Remove check for pattern stmts.
+ (vect_is_simple_reduction_1): Remove dead code.
+ * tree-vect-slp.c (vect_create_oprnd_info): Initialize second_pattern.
+ (vect_get_and_check_slp_defs): Pass in the stmt number.
+ Allow the first def in a reduction to be not a pattern stmt when
+ the rest of the stmts def are patterns.
+ (vect_build_slp_tree_1): Allow tcc_expression codes like
+ SAD_EXPR and DOT_PROD_EXPR.
+ (vect_build_slp_tree): Adjust.
+ (vect_analyze_slp): Refactor and move BB vect error message ...
+ (vect_slp_analyze_bb_1): ... here.
+
2015-05-22 Aldy Hernandez <aldyh@redhat.com>
* tree-switch-conversion.c (build_one_array): Set DECL_IGNORED_P
{
gimple stmt = gsi_stmt (si);
stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
- gcc_assert (stmt_info);
+ if (STMT_VINFO_IN_PATTERN_P (stmt_info)
+ && STMT_VINFO_RELATED_STMT (stmt_info))
+ {
+ stmt = STMT_VINFO_RELATED_STMT (stmt_info);
+ stmt_info = vinfo_for_stmt (stmt);
+ }
if ((STMT_VINFO_RELEVANT_P (stmt_info)
|| VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE (stmt_info)))
&& !PURE_SLP_STMT (stmt_info))
if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
{
- if (vinfo_for_stmt (use_stmt)
- && !STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (use_stmt)))
- {
- loop_use_stmt = use_stmt;
- nloop_uses++;
- }
+ loop_use_stmt = use_stmt;
+ nloop_uses++;
}
else
n_out_of_loop_uses++;
return NULL;
}
- if (vinfo_for_stmt (use_stmt)
- && !is_pattern_stmt_p (vinfo_for_stmt (use_stmt)))
- nloop_uses++;
+ nloop_uses++;
if (nloop_uses > 1)
{
if (dump_enabled_p ())
gimple use_stmt = USE_STMT (use_p);
if (is_gimple_debug (use_stmt))
continue;
- if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))
- && vinfo_for_stmt (use_stmt)
- && !is_pattern_stmt_p (vinfo_for_stmt (use_stmt)))
+ if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
nloop_uses++;
if (nloop_uses > 1)
{
oprnd_info->first_dt = vect_uninitialized_def;
oprnd_info->first_op_type = NULL_TREE;
oprnd_info->first_pattern = false;
+ oprnd_info->second_pattern = false;
oprnds_info.quick_push (oprnd_info);
}
static int
vect_get_and_check_slp_defs (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
- gimple stmt, bool first,
+ gimple stmt, unsigned stmt_num,
vec<slp_oprnd_info> *oprnds_info)
{
tree oprnd;
int first_op_idx = 1;
bool commutative = false;
bool first_op_cond = false;
+ bool first = stmt_num == 0;
+ bool second = stmt_num == 1;
if (loop_vinfo)
loop = LOOP_VINFO_LOOP (loop_vinfo);
&& !STMT_VINFO_LIVE_P (vinfo_for_stmt (def_stmt)))
{
pattern = true;
- if (!first && !oprnd_info->first_pattern)
+ if (!first && !oprnd_info->first_pattern
+ /* Allow different pattern state for the defs of the
+ first stmt in reduction chains. */
+ && (oprnd_info->first_dt != vect_reduction_def
+ || (!second && !oprnd_info->second_pattern)))
{
if (i == 0
&& !swapped
}
}
+ if (second)
+ oprnd_info->second_pattern = pattern;
+
if (first)
{
oprnd_info->first_dt = dt;
/* Not memory operation. */
if (TREE_CODE_CLASS (rhs_code) != tcc_binary
&& TREE_CODE_CLASS (rhs_code) != tcc_unary
- && rhs_code != COND_EXPR
+ && TREE_CODE_CLASS (rhs_code) != tcc_expression
&& rhs_code != CALL_EXPR)
{
if (dump_enabled_p ())
FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (*node), i, stmt)
{
switch (vect_get_and_check_slp_defs (loop_vinfo, bb_vinfo,
- stmt, (i == 0), &oprnds_info))
+ stmt, i, &oprnds_info))
{
case 0:
break;
max_tree_size))
ok = true;
- if (bb_vinfo && !ok)
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "Failed to SLP the basic block.\n");
-
- return false;
- }
-
- if (loop_vinfo
- && LOOP_VINFO_REDUCTION_CHAINS (loop_vinfo).length () > 0)
+ if (reduc_chains.length () > 0)
{
/* Find SLP sequences starting from reduction chains. */
FOR_EACH_VEC_ELT (reduc_chains, i, first_element)
}
/* Find SLP sequences starting from groups of reductions. */
- if (loop_vinfo && LOOP_VINFO_REDUCTIONS (loop_vinfo).length () > 1
+ if (reductions.length () > 1
&& vect_analyze_slp_instance (loop_vinfo, bb_vinfo, reductions[0],
max_tree_size))
ok = true;
if (!vect_analyze_slp (NULL, bb_vinfo, n_stmts))
{
if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "not vectorized: failed to find SLP opportunities "
- "in basic block.\n");
+ {
+ dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+ "Failed to SLP the basic block.\n");
+ dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+ "not vectorized: failed to find SLP opportunities "
+ "in basic block.\n");
+ }
destroy_bb_vec_info (bb_vinfo);
return NULL;