From: Richard Biener Date: Wed, 9 May 2018 13:04:00 +0000 (+0000) Subject: tree-vect-slp.c (vect_bb_slp_scalar_cost): Fill a cost vector. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a296d6d3bdd83a617e789641b828ff53f65a4ec6;p=gcc.git tree-vect-slp.c (vect_bb_slp_scalar_cost): Fill a cost vector. 2018-05-09 Richard Biener * tree-vect-slp.c (vect_bb_slp_scalar_cost): Fill a cost vector. (vect_bb_vectorization_profitable_p): Adjust. Compute actual scalar cost using the cost vector and the add_stmt_cost machinery. From-SVN: r260078 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0acd815b35c..50eaef9a2c5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2018-05-09 Richard Biener + + * tree-vect-slp.c (vect_bb_slp_scalar_cost): Fill a cost + vector. + (vect_bb_vectorization_profitable_p): Adjust. Compute + actual scalar cost using the cost vector and the add_stmt_cost + machinery. + 2018-05-09 Segher Boessenkool PR rtl-optimization/85645 diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 48ed96bb7b9..4639bfc87c8 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -2886,18 +2886,17 @@ vect_slp_analyze_operations (vec_info *vinfo) and return it. Do not account defs that are marked in LIFE and update LIFE according to uses of NODE. */ -static unsigned +static void vect_bb_slp_scalar_cost (basic_block bb, - slp_tree node, vec *life) + slp_tree node, vec *life, + stmt_vector_for_cost *cost_vec) { - unsigned scalar_cost = 0; unsigned i; gimple *stmt; slp_tree child; FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), i, stmt) { - unsigned stmt_cost; ssa_op_iter op_iter; def_operand_p def_p; stmt_vec_info stmt_info; @@ -2933,17 +2932,17 @@ vect_bb_slp_scalar_cost (basic_block bb, gimple_set_visited (stmt, true); stmt_info = vinfo_for_stmt (stmt); + vect_cost_for_stmt kind; if (STMT_VINFO_DATA_REF (stmt_info)) { if (DR_IS_READ (STMT_VINFO_DATA_REF (stmt_info))) - stmt_cost = vect_get_stmt_cost (scalar_load); + kind = scalar_load; else - stmt_cost = vect_get_stmt_cost (scalar_store); + kind = scalar_store; } else - stmt_cost = vect_get_stmt_cost (scalar_stmt); - - scalar_cost += stmt_cost; + kind = scalar_stmt; + record_stmt_cost (cost_vec, 1, kind, stmt_info, 0, vect_body); } auto_vec subtree_life; @@ -2954,12 +2953,10 @@ vect_bb_slp_scalar_cost (basic_block bb, /* Do not directly pass LIFE to the recursive call, copy it to confine changes in the callee to the current child/subtree. */ subtree_life.safe_splice (*life); - scalar_cost += vect_bb_slp_scalar_cost (bb, child, &subtree_life); + vect_bb_slp_scalar_cost (bb, child, &subtree_life, cost_vec); subtree_life.truncate (0); } } - - return scalar_cost; } /* Check if vectorization of the basic block is profitable. */ @@ -2974,14 +2971,30 @@ vect_bb_vectorization_profitable_p (bb_vec_info bb_vinfo) unsigned int vec_prologue_cost = 0, vec_epilogue_cost = 0; /* Calculate scalar cost. */ + stmt_vector_for_cost scalar_costs; + scalar_costs.create (0); FOR_EACH_VEC_ELT (slp_instances, i, instance) { auto_vec life; life.safe_grow_cleared (SLP_INSTANCE_GROUP_SIZE (instance)); - scalar_cost += vect_bb_slp_scalar_cost (BB_VINFO_BB (bb_vinfo), - SLP_INSTANCE_TREE (instance), - &life); + vect_bb_slp_scalar_cost (BB_VINFO_BB (bb_vinfo), + SLP_INSTANCE_TREE (instance), + &life, &scalar_costs); + } + void *target_cost_data = init_cost (NULL); + stmt_info_for_cost *si; + FOR_EACH_VEC_ELT (scalar_costs, i, si) + { + struct _stmt_vec_info *stmt_info + = si->stmt ? vinfo_for_stmt (si->stmt) : NULL; + (void) add_stmt_cost (target_cost_data, si->count, + si->kind, stmt_info, si->misalign, + vect_body); } + scalar_costs.release (); + unsigned dummy; + finish_cost (target_cost_data, &dummy, &scalar_cost, &dummy); + destroy_cost_data (target_cost_data); /* Unset visited flag. */ for (gimple_stmt_iterator gsi = bb_vinfo->region_begin;