diff options
author | Ira Rosen <irar@il.ibm.com> | 2010-06-07 09:12:32 +0000 |
---|---|---|
committer | Ira Rosen <irar@gcc.gnu.org> | 2010-06-07 09:12:32 +0000 |
commit | 35e1a5e7cf85b08634a46b08e76d28ced021aff9 (patch) | |
tree | 8795ce881dcce2d97198c58aa7cb9c8a103a4f24 /gcc/tree-vect-loop.c | |
parent | 81c566c2fa32ad31b8b22f7ada161778150e51d1 (diff) | |
download | gcc-35e1a5e7cf85b08634a46b08e76d28ced021aff9.zip gcc-35e1a5e7cf85b08634a46b08e76d28ced021aff9.tar.gz gcc-35e1a5e7cf85b08634a46b08e76d28ced021aff9.tar.bz2 |
tm.texi (TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST): Update documentation.
* doc/tm.texi (TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST): Update
documentation.
* targhooks.c (default_builtin_vectorization_cost): New function.
* targhooks.h (default_builtin_vectorization_cost): Declare.
* target.h (enum vect_cost_for_stmt): Define.
(builtin_vectorization_cost): Change argument and comment.
* tree-vectorizer.h: Remove cost model macros.
* tree-vect-loop.c: Include target.h.
(vect_get_cost): New function.
(vect_estimate_min_profitable_iters): Replace cost model macros with
calls to vect_get_cost.
(vect_model_reduction_cost, vect_model_induction_cost): Likewise.
* target-def.h (TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST): Add
default implementation.
* tree-vect-stmts.c (cost_for_stmt): Replace cost model macros with
calls to target hook builtin_vectorization_cost.
(vect_model_simple_cost, vect_model_store_cost, vect_model_load_cost):
Likewise.
* Makefile.in (tree-vect-loop.o): Add dependency on TARGET_H.
* config/spu/spu.c (spu_builtin_vectorization_cost): Replace with new
implementation to return costs.
* config/i386/i386.c (ix86_builtin_vectorization_cost): Likewise.
* config/spu/spu.h: Remove vectorizer cost model macros.
* config/i386/i386.h: Likewise.
* tree-vect-slp.c (vect_build_slp_tree): Replace cost model macro with
a call to target hook builtin_vectorization_cost.
From-SVN: r160360
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r-- | gcc/tree-vect-loop.c | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index a6b331a..ccddab3 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-chrec.h" #include "tree-scalar-evolution.h" #include "tree-vectorizer.h" +#include "target.h" /* Loop Vectorization Pass. @@ -1116,6 +1117,15 @@ 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) +{ + return targetm.vectorize.builtin_vectorization_cost (type_of_cost); +} + + /* Function vect_analyze_loop_operations. Scan the loop stmts and make sure they are all vectorizable. */ @@ -2056,7 +2066,7 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo) if (LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT (loop_vinfo) || LOOP_REQUIRES_VERSIONING_FOR_ALIAS (loop_vinfo)) - vec_outside_cost += TARG_COND_TAKEN_BRANCH_COST; + vec_outside_cost += vect_get_cost (cond_branch_taken); /* Count statements in scalar loop. Using this as scalar cost for a single iteration for now. @@ -2125,8 +2135,8 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo) 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 * (TARG_COND_TAKEN_BRANCH_COST - + TARG_COND_NOT_TAKEN_BRANCH_COST); + peel_guard_costs += 2 * (vect_get_cost (cond_branch_taken) + + vect_get_cost (cond_branch_not_taken)); } else { @@ -2152,8 +2162,7 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo) /* If peeled iterations are known but number of scalar loop iterations are unknown, count a taken branch per peeled loop. */ - peel_guard_costs += 2 * TARG_COND_TAKEN_BRANCH_COST; - + peel_guard_costs += 2 * vect_get_cost (cond_branch_taken); } else { @@ -2228,16 +2237,16 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo) /* Cost model check occurs at versioning. */ if (LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT (loop_vinfo) || LOOP_REQUIRES_VERSIONING_FOR_ALIAS (loop_vinfo)) - scalar_outside_cost += TARG_COND_NOT_TAKEN_BRANCH_COST; + scalar_outside_cost += vect_get_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 * TARG_COND_TAKEN_BRANCH_COST - + TARG_COND_NOT_TAKEN_BRANCH_COST; + scalar_outside_cost += 2 * vect_get_cost (cond_branch_taken) + + vect_get_cost (cond_branch_not_taken); /* Cost model check occurs at epilogue generation. */ else - scalar_outside_cost += 2 * TARG_COND_TAKEN_BRANCH_COST; + scalar_outside_cost += 2 * vect_get_cost (cond_branch_taken); } } @@ -2347,7 +2356,8 @@ vect_model_reduction_cost (stmt_vec_info stmt_info, enum tree_code reduc_code, /* Cost of reduction op inside loop. */ - STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info) += ncopies * TARG_VEC_STMT_COST; + STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info) + += ncopies * vect_get_cost (vector_stmt); stmt = STMT_VINFO_STMT (stmt_info); @@ -2387,7 +2397,7 @@ vect_model_reduction_cost (stmt_vec_info stmt_info, enum tree_code reduc_code, code = gimple_assign_rhs_code (orig_stmt); /* Add in cost for initial definition. */ - outer_cost += TARG_SCALAR_TO_VEC_COST; + outer_cost += vect_get_cost (scalar_to_vec); /* Determine cost of epilogue code. @@ -2397,7 +2407,8 @@ vect_model_reduction_cost (stmt_vec_info stmt_info, enum tree_code reduc_code, if (!nested_in_vect_loop_p (loop, orig_stmt)) { if (reduc_code != ERROR_MARK) - outer_cost += TARG_VEC_STMT_COST + TARG_VEC_TO_SCALAR_COST; + outer_cost += vect_get_cost (vector_stmt) + + vect_get_cost (vec_to_scalar); else { int vec_size_in_bits = tree_low_cst (TYPE_SIZE (vectype), 1); @@ -2414,12 +2425,14 @@ vect_model_reduction_cost (stmt_vec_info stmt_info, enum tree_code reduc_code, && optab_handler (vec_shr_optab, mode)->insn_code != CODE_FOR_nothing) /* Final reduction via vector shifts and the reduction operator. Also requires scalar extract. */ - outer_cost += ((exact_log2(nelements) * 2) * TARG_VEC_STMT_COST - + TARG_VEC_TO_SCALAR_COST); + outer_cost += ((exact_log2(nelements) * 2) + * vect_get_cost (vector_stmt) + + vect_get_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) * TARG_VEC_STMT_COST); + outer_cost += ((nelements + nelements - 1) + * vect_get_cost (vector_stmt)); } } @@ -2442,9 +2455,11 @@ static void vect_model_induction_cost (stmt_vec_info stmt_info, int ncopies) { /* loop cost for vec_loop. */ - STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info) = ncopies * TARG_VEC_STMT_COST; + STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info) + = ncopies * vect_get_cost (vector_stmt); /* prologue cost for vec_init and vec_step. */ - STMT_VINFO_OUTSIDE_OF_LOOP_COST (stmt_info) = 2 * TARG_SCALAR_TO_VEC_COST; + STMT_VINFO_OUTSIDE_OF_LOOP_COST (stmt_info) + = 2 * vect_get_cost (scalar_to_vec); if (vect_print_dump_info (REPORT_COST)) fprintf (vect_dump, "vect_model_induction_cost: inside_cost = %d, " |