On Wed, 13 Jun 2012, William J. Schmidt wrote: > This is just some general maintenance to the vectorizer's cost model > code: > > * Corrects a typo in a function name; > * Eliminates an unnecessary function; > * Combines some duplicate inline functions. > > Bootstrapped and tested on powerpc64-unknown-linux-gnu, no new > regressions. Ok for trunk?
Ok. Thanks for doing this, Richard. > Thanks, > Bill > > > 2012-06-13 Bill Schmidt <wschm...@linux.ibm.com> > > * tree-vectorizer.h (vect_get_stmt_cost): Move from tree-vect-stmts.c. > (cost_for_stmt): Remove decl. > (vect_get_single_scalar_iteration_cost): Correct typo in name. > * tree-vect-loop.c (vect_get_cost): Remove. > (vect_get_single_scalar_iteration_cost): Correct typo in name; use > vect_get_stmt_cost rather than vect_get_cost. > (vect_get_known_peeling_cost): Use vect_get_stmt_cost rather than > vect_get_cost. > (vect_estimate_min_profitable_iters): Correct typo in call to > vect_get_single_scalar_iteration_cost; use vect_get_stmt_cost rather > than vect_get_cost. > (vect_model_reduction_cost): Use vect_get_stmt_cost rather than > vect_get_cost. > (vect_model_induction_cost): Likewise. > * tree-vect-data-refs.c (vect_peeling_hash_get_lowest_cost): Correct > typo in call to vect_get_single_scalar_iteration_cost. > * tree-vect-stmts.c (vect_get_stmt_cost): Move to tree-vectorizer.h. > (cost_for_stmt): Remove unnecessary function. > * Makefile.in (TREE_VECTORIZER_H): Update dependencies. > > > Index: gcc/tree-vectorizer.h > =================================================================== > --- gcc/tree-vectorizer.h (revision 188507) > +++ gcc/tree-vectorizer.h (working copy) > @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see > #define GCC_TREE_VECTORIZER_H > > #include "tree-data-ref.h" > +#include "target.h" > > typedef source_location LOC; > #define UNKNOWN_LOC UNKNOWN_LOCATION > @@ -769,6 +770,18 @@ vect_pow2 (int x) > return res; > } > > +/* Get cost by calling cost target builtin. */ > + > +static inline > +int vect_get_stmt_cost (enum vect_cost_for_stmt type_of_cost) > +{ > + tree dummy_type = NULL; > + int dummy = 0; > + > + return targetm.vectorize.builtin_vectorization_cost (type_of_cost, > + dummy_type, dummy); > +} > + > /*-----------------------------------------------------------------*/ > /* Info on data references alignment. */ > /*-----------------------------------------------------------------*/ > @@ -843,7 +856,6 @@ extern void vect_model_load_cost (stmt_vec_info, i > extern void vect_finish_stmt_generation (gimple, gimple, > gimple_stmt_iterator *); > extern bool vect_mark_stmts_to_be_vectorized (loop_vec_info); > -extern int cost_for_stmt (gimple); > extern tree vect_get_vec_def_for_operand (tree, gimple, tree *); > extern tree vect_init_vector (gimple, tree, tree, > gimple_stmt_iterator *); > @@ -919,7 +931,7 @@ extern int vect_estimate_min_profitable_iters (loo > extern tree get_initial_def_for_reduction (gimple, tree, tree *); > extern int vect_min_worthwhile_factor (enum tree_code); > extern int vect_get_known_peeling_cost (loop_vec_info, int, int *, int); > -extern int vect_get_single_scalar_iteraion_cost (loop_vec_info); > +extern int vect_get_single_scalar_iteration_cost (loop_vec_info); > > /* In tree-vect-slp.c. */ > extern void vect_free_slp_instance (slp_instance); > Index: gcc/tree-vect-loop.c > =================================================================== > --- gcc/tree-vect-loop.c (revision 188507) > +++ gcc/tree-vect-loop.c (working copy) > @@ -1201,19 +1201,6 @@ vect_analyze_loop_form (struct loop *loop) > } > > > -/* Get cost by calling cost target builtin. */ > - > -static inline int > -vect_get_cost (enum vect_cost_for_stmt type_of_cost) > -{ > - tree dummy_type = NULL; > - int dummy = 0; > - > - return targetm.vectorize.builtin_vectorization_cost (type_of_cost, > - dummy_type, dummy); > -} > - > - > /* Function vect_analyze_loop_operations. > > Scan the loop stmts and make sure they are all vectorizable. */ > @@ -2385,7 +2372,7 @@ vect_force_simple_reduction (loop_vec_info loop_in > > /* Calculate the cost of one scalar iteration of the loop. */ > int > -vect_get_single_scalar_iteraion_cost (loop_vec_info loop_vinfo) > +vect_get_single_scalar_iteration_cost (loop_vec_info loop_vinfo) > { > struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo); > basic_block *bbs = LOOP_VINFO_BBS (loop_vinfo); > @@ -2434,12 +2421,12 @@ int > if (STMT_VINFO_DATA_REF (vinfo_for_stmt (stmt))) > { > if (DR_IS_READ (STMT_VINFO_DATA_REF (vinfo_for_stmt (stmt)))) > - stmt_cost = vect_get_cost (scalar_load); > + stmt_cost = vect_get_stmt_cost (scalar_load); > else > - stmt_cost = vect_get_cost (scalar_store); > + stmt_cost = vect_get_stmt_cost (scalar_store); > } > else > - stmt_cost = vect_get_cost (scalar_stmt); > + stmt_cost = vect_get_stmt_cost (scalar_stmt); > > scalar_single_iter_cost += stmt_cost * factor; > } > @@ -2466,7 +2453,7 @@ vect_get_known_peeling_cost (loop_vec_info loop_vi > > /* If peeled iterations are known but number of scalar loop > iterations are unknown, count a taken branch per peeled loop. */ > - peel_guard_costs = 2 * vect_get_cost (cond_branch_taken); > + peel_guard_costs = 2 * vect_get_stmt_cost (cond_branch_taken); > } > else > { > @@ -2547,7 +2534,7 @@ vect_estimate_min_profitable_iters (loop_vec_info > > if (LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT (loop_vinfo) > || LOOP_REQUIRES_VERSIONING_FOR_ALIAS (loop_vinfo)) > - vec_outside_cost += vect_get_cost (cond_branch_taken); > + vec_outside_cost += vect_get_stmt_cost (cond_branch_taken); > > /* Count statements in scalar loop. Using this as scalar cost for a single > iteration for now. > @@ -2618,7 +2605,7 @@ vect_estimate_min_profitable_iters (loop_vec_info > } > } > > - scalar_single_iter_cost = vect_get_single_scalar_iteraion_cost > (loop_vinfo); > + scalar_single_iter_cost = vect_get_single_scalar_iteration_cost > (loop_vinfo); > > /* Add additional cost for the peeled instructions in prologue and epilogue > loop. > @@ -2648,8 +2635,8 @@ vect_estimate_min_profitable_iters (loop_vec_info > branch per peeled loop. Even if scalar loop iterations are known, > vector iterations are not known since peeled prologue iterations are > not known. Hence guards remain the same. */ > - peel_guard_costs += 2 * (vect_get_cost (cond_branch_taken) > - + vect_get_cost (cond_branch_not_taken)); > + peel_guard_costs += 2 * (vect_get_stmt_cost (cond_branch_taken) > + + vect_get_stmt_cost > (cond_branch_not_taken)); > vec_outside_cost += (peel_iters_prologue * scalar_single_iter_cost) > + (peel_iters_epilogue * scalar_single_iter_cost) > + peel_guard_costs; > @@ -2722,16 +2709,16 @@ vect_estimate_min_profitable_iters (loop_vec_info > /* Cost model check occurs at versioning. */ > if (LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT (loop_vinfo) > || LOOP_REQUIRES_VERSIONING_FOR_ALIAS (loop_vinfo)) > - scalar_outside_cost += vect_get_cost (cond_branch_not_taken); > + scalar_outside_cost += vect_get_stmt_cost (cond_branch_not_taken); > else > { > /* Cost model check occurs at prologue generation. */ > if (LOOP_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0) > - scalar_outside_cost += 2 * vect_get_cost (cond_branch_taken) > - + vect_get_cost (cond_branch_not_taken); > + scalar_outside_cost += 2 * vect_get_stmt_cost (cond_branch_taken) > + + vect_get_stmt_cost (cond_branch_not_taken); > /* Cost model check occurs at epilogue generation. */ > else > - scalar_outside_cost += 2 * vect_get_cost (cond_branch_taken); > + scalar_outside_cost += 2 * vect_get_stmt_cost (cond_branch_taken); > } > } > > @@ -2842,7 +2829,7 @@ vect_model_reduction_cost (stmt_vec_info stmt_info > > /* Cost of reduction op inside loop. */ > STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info) > - += ncopies * vect_get_cost (vector_stmt); > + += ncopies * vect_get_stmt_cost (vector_stmt); > > stmt = STMT_VINFO_STMT (stmt_info); > > @@ -2885,7 +2872,7 @@ vect_model_reduction_cost (stmt_vec_info stmt_info > code = gimple_assign_rhs_code (orig_stmt); > > /* Add in cost for initial definition. */ > - outer_cost += vect_get_cost (scalar_to_vec); > + outer_cost += vect_get_stmt_cost (scalar_to_vec); > > /* Determine cost of epilogue code. > > @@ -2895,8 +2882,8 @@ vect_model_reduction_cost (stmt_vec_info stmt_info > if (!nested_in_vect_loop_p (loop, orig_stmt)) > { > if (reduc_code != ERROR_MARK) > - outer_cost += vect_get_cost (vector_stmt) > - + vect_get_cost (vec_to_scalar); > + outer_cost += vect_get_stmt_cost (vector_stmt) > + + vect_get_stmt_cost (vec_to_scalar); > else > { > int vec_size_in_bits = tree_low_cst (TYPE_SIZE (vectype), 1); > @@ -2914,13 +2901,13 @@ vect_model_reduction_cost (stmt_vec_info stmt_info > /* Final reduction via vector shifts and the reduction operator. > Also > requires scalar extract. */ > outer_cost += ((exact_log2(nelements) * 2) > - * vect_get_cost (vector_stmt) > - + vect_get_cost (vec_to_scalar)); > + * vect_get_stmt_cost (vector_stmt) > + + vect_get_stmt_cost (vec_to_scalar)); > else > /* Use extracts and reduction op for final reduction. For N > elements, > we have N extracts and N-1 reduction ops. */ > outer_cost += ((nelements + nelements - 1) > - * vect_get_cost (vector_stmt)); > + * vect_get_stmt_cost (vector_stmt)); > } > } > > @@ -2944,10 +2931,10 @@ vect_model_induction_cost (stmt_vec_info stmt_info > { > /* loop cost for vec_loop. */ > STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info) > - = ncopies * vect_get_cost (vector_stmt); > + = ncopies * vect_get_stmt_cost (vector_stmt); > /* prologue cost for vec_init and vec_step. */ > STMT_VINFO_OUTSIDE_OF_LOOP_COST (stmt_info) > - = 2 * vect_get_cost (scalar_to_vec); > + = 2 * vect_get_stmt_cost (scalar_to_vec); > > if (vect_print_dump_info (REPORT_COST)) > fprintf (vect_dump, "vect_model_induction_cost: inside_cost = %d, " > Index: gcc/tree-vect-data-refs.c > =================================================================== > --- gcc/tree-vect-data-refs.c (revision 188507) > +++ gcc/tree-vect-data-refs.c (working copy) > @@ -1320,7 +1320,7 @@ vect_peeling_hash_get_lowest_cost (void **slot, vo > } > > outside_cost += vect_get_known_peeling_cost (loop_vinfo, elem->npeel, > &dummy, > - vect_get_single_scalar_iteraion_cost (loop_vinfo)); > + vect_get_single_scalar_iteration_cost (loop_vinfo)); > > if (inside_cost < min->inside_cost > || (inside_cost == min->inside_cost && outside_cost < > min->outside_cost)) > Index: gcc/tree-vect-stmts.c > =================================================================== > --- gcc/tree-vect-stmts.c (revision 188508) > +++ gcc/tree-vect-stmts.c (working copy) > @@ -727,48 +727,6 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo > } > > > -/* Get cost by calling cost target builtin. */ > - > -static inline > -int vect_get_stmt_cost (enum vect_cost_for_stmt type_of_cost) > -{ > - tree dummy_type = NULL; > - int dummy = 0; > - > - return targetm.vectorize.builtin_vectorization_cost (type_of_cost, > - dummy_type, dummy); > -} > - > - > -/* Get cost for STMT. */ > - > -int > -cost_for_stmt (gimple stmt) > -{ > - stmt_vec_info stmt_info = vinfo_for_stmt (stmt); > - > - switch (STMT_VINFO_TYPE (stmt_info)) > - { > - case load_vec_info_type: > - return vect_get_stmt_cost (scalar_load); > - case store_vec_info_type: > - return vect_get_stmt_cost (scalar_store); > - case op_vec_info_type: > - case condition_vec_info_type: > - case assignment_vec_info_type: > - case reduc_vec_info_type: > - case induc_vec_info_type: > - case type_promotion_vec_info_type: > - case type_demotion_vec_info_type: > - case type_conversion_vec_info_type: > - case call_vec_info_type: > - return vect_get_stmt_cost (scalar_stmt); > - case undef_vec_info_type: > - default: > - gcc_unreachable (); > - } > -} > - > /* Function vect_model_simple_cost. > > Models cost for simple operations, i.e. those that only emit ncopies of a > Index: gcc/Makefile.in > =================================================================== > --- gcc/Makefile.in (revision 188507) > +++ gcc/Makefile.in (working copy) > @@ -965,7 +965,7 @@ GIMPLE_STREAMER_H = gimple-streamer.h $(LTO_STREAM > TREE_STREAMER_H = tree-streamer.h $(TREE_H) $(LTO_STREAMER_H) \ > $(STREAMER_HOOKS_H) > STREAMER_HOOKS_H = streamer-hooks.h $(TREE_H) > -TREE_VECTORIZER_H = tree-vectorizer.h $(TREE_DATA_REF_H) > +TREE_VECTORIZER_H = tree-vectorizer.h $(TREE_DATA_REF_H) $(TARGET_H) > IPA_PROP_H = ipa-prop.h $(TREE_H) $(VEC_H) $(CGRAPH_H) $(GIMPLE_H) > alloc-pool.h > GSTAB_H = gstab.h stab.def > BITMAP_H = bitmap.h $(HASHTAB_H) statistics.h > > > -- Richard Guenther <rguent...@suse.de> SUSE / SUSE Labs SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 GF: Jeff Hawn, Jennifer Guild, Felix Imend