Commit 89675e73 by Ira Rosen Committed by Ira Rosen

tree-vectorizer.h (stmt_vinfo_set_inside_of_loop_cost, [...]): New functions.

	* tree-vectorizer.h (stmt_vinfo_set_inside_of_loop_cost,
	stmt_vinfo_set_outside_of_loop_cost): New functions.
	* tree-vect-transform.c (vect_get_cost_fields): Remove.
	(vect_model_simple_cost): Call
	stmt_vinfo_set_inside/outside_of_loop_cost to set the relevant cost
	field instead of calling vect_get_cost_fields.
	(vect_model_store_cost, vect_model_load_cost): Likewise.

From-SVN: r128294
parent 23a651fc
2007-09-09 Ira Rosen <irar@il.ibm.com>
* tree-vectorizer.h (stmt_vinfo_set_inside_of_loop_cost,
stmt_vinfo_set_outside_of_loop_cost): New functions.
* tree-vect-transform.c (vect_get_cost_fields): Remove.
(vect_model_simple_cost): Call
stmt_vinfo_set_inside/outside_of_loop_cost to set the relevant cost
field instead of calling vect_get_cost_fields.
(vect_model_store_cost, vect_model_load_cost): Likewise.
2007-09-09 Revital Eres <eres@il.ibm.com> 2007-09-09 Revital Eres <eres@il.ibm.com>
* config/rs6000/rs6000.c (paired_init_builtins): Add const * config/rs6000/rs6000.c (paired_init_builtins): Add const
...@@ -462,26 +462,6 @@ vect_model_induction_cost (stmt_vec_info stmt_info, int ncopies) ...@@ -462,26 +462,6 @@ vect_model_induction_cost (stmt_vec_info stmt_info, int ncopies)
} }
/* Return addresses of the cost fields of SLP_NODE if it's not NULL, and of
the stmt otherwise. */
static inline void
vect_get_cost_fields (stmt_vec_info stmt_info, slp_tree slp_node,
int **inside_cost_field, int **outside_cost_field)
{
if (slp_node)
{
*inside_cost_field = &(SLP_TREE_INSIDE_OF_LOOP_COST (slp_node));
*outside_cost_field = &(SLP_TREE_OUTSIDE_OF_LOOP_COST (slp_node));
}
else
{
*inside_cost_field = &(STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info));
*outside_cost_field = &(STMT_VINFO_OUTSIDE_OF_LOOP_COST (stmt_info));
}
}
/* Function vect_model_simple_cost. /* Function vect_model_simple_cost.
Models cost for simple operations, i.e. those that only emit ncopies of a Models cost for simple operations, i.e. those that only emit ncopies of a
...@@ -493,24 +473,24 @@ vect_model_simple_cost (stmt_vec_info stmt_info, int ncopies, ...@@ -493,24 +473,24 @@ vect_model_simple_cost (stmt_vec_info stmt_info, int ncopies,
enum vect_def_type *dt, slp_tree slp_node) enum vect_def_type *dt, slp_tree slp_node)
{ {
int i; int i;
int *inside_cost_field, *outside_cost_field; int inside_cost = 0, outside_cost = 0;
/* Take addresses of relevant fields to update in the function. */ inside_cost = ncopies * TARG_VEC_STMT_COST;
vect_get_cost_fields (stmt_info, slp_node, &inside_cost_field,
&outside_cost_field);
*inside_cost_field = ncopies * TARG_VEC_STMT_COST;
/* FORNOW: Assuming maximum 2 args per stmts. */ /* FORNOW: Assuming maximum 2 args per stmts. */
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
{ {
if (dt[i] == vect_constant_def || dt[i] == vect_invariant_def) if (dt[i] == vect_constant_def || dt[i] == vect_invariant_def)
*outside_cost_field += TARG_SCALAR_TO_VEC_COST; outside_cost += TARG_SCALAR_TO_VEC_COST;
} }
if (vect_print_dump_info (REPORT_DETAILS)) if (vect_print_dump_info (REPORT_DETAILS))
fprintf (vect_dump, "vect_model_simple_cost: inside_cost = %d, " fprintf (vect_dump, "vect_model_simple_cost: inside_cost = %d, "
"outside_cost = %d .", *inside_cost_field, *outside_cost_field); "outside_cost = %d .", inside_cost, outside_cost);
/* Set the costs either in STMT_INFO or SLP_NODE (if exists). */
stmt_vinfo_set_inside_of_loop_cost (stmt_info, slp_node, inside_cost);
stmt_vinfo_set_outside_of_loop_cost (stmt_info, slp_node, outside_cost);
} }
...@@ -541,16 +521,11 @@ void ...@@ -541,16 +521,11 @@ void
vect_model_store_cost (stmt_vec_info stmt_info, int ncopies, vect_model_store_cost (stmt_vec_info stmt_info, int ncopies,
enum vect_def_type dt, slp_tree slp_node) enum vect_def_type dt, slp_tree slp_node)
{ {
int cost = 0;
int group_size; int group_size;
int *inside_cost_field, *outside_cost_field; int inside_cost = 0, outside_cost = 0;
/* Take addresses of relevant fields to update in the function. */
vect_get_cost_fields (stmt_info, slp_node, &inside_cost_field,
&outside_cost_field);
if (dt == vect_constant_def || dt == vect_invariant_def) if (dt == vect_constant_def || dt == vect_invariant_def)
*outside_cost_field = TARG_SCALAR_TO_VEC_COST; outside_cost = TARG_SCALAR_TO_VEC_COST;
/* Strided access? */ /* Strided access? */
if (DR_GROUP_FIRST_DR (stmt_info)) if (DR_GROUP_FIRST_DR (stmt_info))
...@@ -564,7 +539,7 @@ vect_model_store_cost (stmt_vec_info stmt_info, int ncopies, ...@@ -564,7 +539,7 @@ vect_model_store_cost (stmt_vec_info stmt_info, int ncopies,
if (group_size > 1) if (group_size > 1)
{ {
/* Uses a high and low interleave operation for each needed permute. */ /* Uses a high and low interleave operation for each needed permute. */
cost = ncopies * exact_log2(group_size) * group_size inside_cost = ncopies * exact_log2(group_size) * group_size
* TARG_VEC_STMT_COST; * TARG_VEC_STMT_COST;
if (vect_print_dump_info (REPORT_DETAILS)) if (vect_print_dump_info (REPORT_DETAILS))
...@@ -574,13 +549,15 @@ vect_model_store_cost (stmt_vec_info stmt_info, int ncopies, ...@@ -574,13 +549,15 @@ vect_model_store_cost (stmt_vec_info stmt_info, int ncopies,
} }
/* Costs of the stores. */ /* Costs of the stores. */
cost += ncopies * TARG_VEC_STORE_COST; inside_cost += ncopies * TARG_VEC_STORE_COST;
*inside_cost_field = cost;
if (vect_print_dump_info (REPORT_DETAILS)) if (vect_print_dump_info (REPORT_DETAILS))
fprintf (vect_dump, "vect_model_store_cost: inside_cost = %d, " fprintf (vect_dump, "vect_model_store_cost: inside_cost = %d, "
"outside_cost = %d .", *inside_cost_field, *outside_cost_field); "outside_cost = %d .", inside_cost, outside_cost);
/* Set the costs either in STMT_INFO or SLP_NODE (if exists). */
stmt_vinfo_set_inside_of_loop_cost (stmt_info, slp_node, inside_cost);
stmt_vinfo_set_outside_of_loop_cost (stmt_info, slp_node, outside_cost);
} }
...@@ -595,16 +572,11 @@ void ...@@ -595,16 +572,11 @@ void
vect_model_load_cost (stmt_vec_info stmt_info, int ncopies, slp_tree slp_node) vect_model_load_cost (stmt_vec_info stmt_info, int ncopies, slp_tree slp_node)
{ {
int inner_cost = 0;
int group_size; int group_size;
int alignment_support_cheme; int alignment_support_cheme;
tree first_stmt; tree first_stmt;
struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info), *first_dr; struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info), *first_dr;
int *inside_cost_field, *outside_cost_field; int inside_cost = 0, outside_cost = 0;
/* Take addresses of relevant fields to update in the function. */
vect_get_cost_fields (stmt_info, slp_node, &inside_cost_field,
&outside_cost_field);
/* Strided accesses? */ /* Strided accesses? */
first_stmt = DR_GROUP_FIRST_DR (stmt_info); first_stmt = DR_GROUP_FIRST_DR (stmt_info);
...@@ -627,8 +599,8 @@ vect_model_load_cost (stmt_vec_info stmt_info, int ncopies, slp_tree slp_node) ...@@ -627,8 +599,8 @@ vect_model_load_cost (stmt_vec_info stmt_info, int ncopies, slp_tree slp_node)
if (group_size > 1) if (group_size > 1)
{ {
/* Uses an even and odd extract operations for each needed permute. */ /* Uses an even and odd extract operations for each needed permute. */
inner_cost = ncopies * exact_log2(group_size) * group_size inside_cost = ncopies * exact_log2(group_size) * group_size
* TARG_VEC_STMT_COST; * TARG_VEC_STMT_COST;
if (vect_print_dump_info (REPORT_DETAILS)) if (vect_print_dump_info (REPORT_DETAILS))
fprintf (vect_dump, "vect_model_load_cost: strided group_size = %d .", fprintf (vect_dump, "vect_model_load_cost: strided group_size = %d .",
...@@ -641,7 +613,7 @@ vect_model_load_cost (stmt_vec_info stmt_info, int ncopies, slp_tree slp_node) ...@@ -641,7 +613,7 @@ vect_model_load_cost (stmt_vec_info stmt_info, int ncopies, slp_tree slp_node)
{ {
case dr_aligned: case dr_aligned:
{ {
inner_cost += ncopies * TARG_VEC_LOAD_COST; inside_cost += ncopies * TARG_VEC_LOAD_COST;
if (vect_print_dump_info (REPORT_DETAILS)) if (vect_print_dump_info (REPORT_DETAILS))
fprintf (vect_dump, "vect_model_load_cost: aligned."); fprintf (vect_dump, "vect_model_load_cost: aligned.");
...@@ -651,7 +623,7 @@ vect_model_load_cost (stmt_vec_info stmt_info, int ncopies, slp_tree slp_node) ...@@ -651,7 +623,7 @@ vect_model_load_cost (stmt_vec_info stmt_info, int ncopies, slp_tree slp_node)
case dr_unaligned_supported: case dr_unaligned_supported:
{ {
/* Here, we assign an additional cost for the unaligned load. */ /* Here, we assign an additional cost for the unaligned load. */
inner_cost += ncopies * TARG_VEC_UNALIGNED_LOAD_COST; inside_cost += ncopies * TARG_VEC_UNALIGNED_LOAD_COST;
if (vect_print_dump_info (REPORT_DETAILS)) if (vect_print_dump_info (REPORT_DETAILS))
fprintf (vect_dump, "vect_model_load_cost: unaligned supported by " fprintf (vect_dump, "vect_model_load_cost: unaligned supported by "
...@@ -661,20 +633,18 @@ vect_model_load_cost (stmt_vec_info stmt_info, int ncopies, slp_tree slp_node) ...@@ -661,20 +633,18 @@ vect_model_load_cost (stmt_vec_info stmt_info, int ncopies, slp_tree slp_node)
} }
case dr_explicit_realign: case dr_explicit_realign:
{ {
inner_cost += ncopies * (2*TARG_VEC_LOAD_COST + TARG_VEC_STMT_COST); inside_cost += ncopies * (2*TARG_VEC_LOAD_COST + TARG_VEC_STMT_COST);
/* FIXME: If the misalignment remains fixed across the iterations of /* FIXME: If the misalignment remains fixed across the iterations of
the containing loop, the following cost should be added to the the containing loop, the following cost should be added to the
outside costs. */ outside costs. */
if (targetm.vectorize.builtin_mask_for_load) if (targetm.vectorize.builtin_mask_for_load)
inner_cost += TARG_VEC_STMT_COST; inside_cost += TARG_VEC_STMT_COST;
break; break;
} }
case dr_explicit_realign_optimized: case dr_explicit_realign_optimized:
{ {
int outer_cost = 0;
if (vect_print_dump_info (REPORT_DETAILS)) if (vect_print_dump_info (REPORT_DETAILS))
fprintf (vect_dump, "vect_model_load_cost: unaligned software " fprintf (vect_dump, "vect_model_load_cost: unaligned software "
"pipelined."); "pipelined.");
...@@ -688,14 +658,12 @@ vect_model_load_cost (stmt_vec_info stmt_info, int ncopies, slp_tree slp_node) ...@@ -688,14 +658,12 @@ vect_model_load_cost (stmt_vec_info stmt_info, int ncopies, slp_tree slp_node)
if ((!DR_GROUP_FIRST_DR (stmt_info)) || group_size > 1 || slp_node) if ((!DR_GROUP_FIRST_DR (stmt_info)) || group_size > 1 || slp_node)
{ {
outer_cost = 2*TARG_VEC_STMT_COST; outside_cost = 2*TARG_VEC_STMT_COST;
if (targetm.vectorize.builtin_mask_for_load) if (targetm.vectorize.builtin_mask_for_load)
outer_cost += TARG_VEC_STMT_COST; outside_cost += TARG_VEC_STMT_COST;
} }
*outside_cost_field = outer_cost;
inner_cost += ncopies * (TARG_VEC_LOAD_COST + TARG_VEC_STMT_COST); inside_cost += ncopies * (TARG_VEC_LOAD_COST + TARG_VEC_STMT_COST);
break; break;
} }
...@@ -703,13 +671,14 @@ vect_model_load_cost (stmt_vec_info stmt_info, int ncopies, slp_tree slp_node) ...@@ -703,13 +671,14 @@ vect_model_load_cost (stmt_vec_info stmt_info, int ncopies, slp_tree slp_node)
default: default:
gcc_unreachable (); gcc_unreachable ();
} }
*inside_cost_field = inner_cost;
if (vect_print_dump_info (REPORT_DETAILS)) if (vect_print_dump_info (REPORT_DETAILS))
fprintf (vect_dump, "vect_model_load_cost: inside_cost = %d, " fprintf (vect_dump, "vect_model_load_cost: inside_cost = %d, "
"outside_cost = %d .", *inside_cost_field, *outside_cost_field); "outside_cost = %d .", inside_cost, outside_cost);
/* Set the costs either in STMT_INFO or SLP_NODE (if exists). */
stmt_vinfo_set_inside_of_loop_cost (stmt_info, slp_node, inside_cost);
stmt_vinfo_set_outside_of_loop_cost (stmt_info, slp_node, outside_cost);
} }
......
...@@ -561,6 +561,27 @@ is_loop_header_bb_p (basic_block bb) ...@@ -561,6 +561,27 @@ is_loop_header_bb_p (basic_block bb)
return false; return false;
} }
static inline void
stmt_vinfo_set_inside_of_loop_cost (stmt_vec_info stmt_info, slp_tree slp_node,
int cost)
{
if (slp_node)
SLP_TREE_INSIDE_OF_LOOP_COST (slp_node) = cost;
else
STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info) = cost;
}
static inline void
stmt_vinfo_set_outside_of_loop_cost (stmt_vec_info stmt_info, slp_tree slp_node,
int cost)
{
if (slp_node)
SLP_TREE_OUTSIDE_OF_LOOP_COST (slp_node) = cost;
else
STMT_VINFO_OUTSIDE_OF_LOOP_COST (stmt_info) = cost;
}
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
/* Info on data references alignment. */ /* Info on data references alignment. */
/*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/
......
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