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/config | |
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/config')
-rw-r--r-- | gcc/config/i386/i386.c | 56 | ||||
-rw-r--r-- | gcc/config/i386/i386.h | 51 | ||||
-rw-r--r-- | gcc/config/spu/spu.c | 43 | ||||
-rw-r--r-- | gcc/config/spu/spu.h | 51 |
4 files changed, 71 insertions, 130 deletions
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 8ae0c24..407238f 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -29296,28 +29296,52 @@ static const struct attribute_spec ix86_attribute_table[] = /* Implement targetm.vectorize.builtin_vectorization_cost. */ static int -ix86_builtin_vectorization_cost (bool runtime_test) +ix86_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost) { - /* If the branch of the runtime test is taken - i.e. - the vectorized - version is skipped - this incurs a misprediction cost (because the - vectorized version is expected to be the fall-through). So we subtract - the latency of a mispredicted branch from the costs that are incured - when the vectorized version is executed. + switch (type_of_cost) + { + case scalar_stmt: + return ix86_cost->scalar_stmt_cost; - TODO: The values in individual target tables have to be tuned or new - fields may be needed. For eg. on K8, the default branch path is the - not-taken path. If the taken path is predicted correctly, the minimum - penalty of going down the taken-path is 1 cycle. If the taken-path is - not predicted correctly, then the minimum penalty is 10 cycles. */ + case scalar_load: + return ix86_cost->scalar_load_cost; - if (runtime_test) - { - return (-(ix86_cost->cond_taken_branch_cost)); + case scalar_store: + return ix86_cost->scalar_store_cost; + + case vector_stmt: + return ix86_cost->vec_stmt_cost; + + case vector_load: + return ix86_cost->vec_align_load_cost; + + case vector_store: + return ix86_cost->vec_store_cost; + + case vec_to_scalar: + return ix86_cost->vec_to_scalar_cost; + + case scalar_to_vec: + return ix86_cost->scalar_to_vec_cost; + + case unaligned_load: + return ix86_cost->vec_unalign_load_cost; + + case cond_branch_taken: + return ix86_cost->cond_taken_branch_cost; + + case cond_branch_not_taken: + return ix86_cost->cond_not_taken_branch_cost; + + case vec_perm: + return 1; + + default: + gcc_unreachable (); } - else - return 0; } + /* Implement targetm.vectorize.builtin_vec_perm. */ static tree diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index c3fc0e4..226f784 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -2420,57 +2420,6 @@ struct GTY(()) machine_function { #define SYMBOL_REF_DLLEXPORT_P(X) \ ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_DLLEXPORT) != 0) -/* Model costs for vectorizer. */ - -/* Cost of conditional branch. */ -#undef TARG_COND_BRANCH_COST -#define TARG_COND_BRANCH_COST ix86_cost->branch_cost - -/* Cost of any scalar operation, excluding load and store. */ -#undef TARG_SCALAR_STMT_COST -#define TARG_SCALAR_STMT_COST ix86_cost->scalar_stmt_cost - -/* Cost of scalar load. */ -#undef TARG_SCALAR_LOAD_COST -#define TARG_SCALAR_LOAD_COST ix86_cost->scalar_load_cost - -/* Cost of scalar store. */ -#undef TARG_SCALAR_STORE_COST -#define TARG_SCALAR_STORE_COST ix86_cost->scalar_store_cost - -/* Cost of any vector operation, excluding load, store or vector to scalar - operation. */ -#undef TARG_VEC_STMT_COST -#define TARG_VEC_STMT_COST ix86_cost->vec_stmt_cost - -/* Cost of vector to scalar operation. */ -#undef TARG_VEC_TO_SCALAR_COST -#define TARG_VEC_TO_SCALAR_COST ix86_cost->vec_to_scalar_cost - -/* Cost of scalar to vector operation. */ -#undef TARG_SCALAR_TO_VEC_COST -#define TARG_SCALAR_TO_VEC_COST ix86_cost->scalar_to_vec_cost - -/* Cost of aligned vector load. */ -#undef TARG_VEC_LOAD_COST -#define TARG_VEC_LOAD_COST ix86_cost->vec_align_load_cost - -/* Cost of misaligned vector load. */ -#undef TARG_VEC_UNALIGNED_LOAD_COST -#define TARG_VEC_UNALIGNED_LOAD_COST ix86_cost->vec_unalign_load_cost - -/* Cost of vector store. */ -#undef TARG_VEC_STORE_COST -#define TARG_VEC_STORE_COST ix86_cost->vec_store_cost - -/* Cost of conditional taken branch for vectorizer cost model. */ -#undef TARG_COND_TAKEN_BRANCH_COST -#define TARG_COND_TAKEN_BRANCH_COST ix86_cost->cond_taken_branch_cost - -/* Cost of conditional not taken branch for vectorizer cost model. */ -#undef TARG_COND_NOT_TAKEN_BRANCH_COST -#define TARG_COND_NOT_TAKEN_BRANCH_COST ix86_cost->cond_not_taken_branch_cost - /* Local variables: version-control: t diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c index 0eff2cc..f8dd305 100644 --- a/gcc/config/spu/spu.c +++ b/gcc/config/spu/spu.c @@ -209,7 +209,7 @@ static rtx spu_addr_space_legitimize_address (rtx, rtx, enum machine_mode, static tree spu_builtin_mul_widen_even (tree); static tree spu_builtin_mul_widen_odd (tree); static tree spu_builtin_mask_for_load (void); -static int spu_builtin_vectorization_cost (bool); +static int spu_builtin_vectorization_cost (enum vect_cost_for_stmt); static bool spu_vector_alignment_reachable (const_tree, bool); static tree spu_builtin_vec_perm (tree, tree *); static enum machine_mode spu_addr_space_pointer_mode (addr_space_t); @@ -6695,17 +6695,36 @@ spu_builtin_mask_for_load (void) /* Implement targetm.vectorize.builtin_vectorization_cost. */ static int -spu_builtin_vectorization_cost (bool runtime_test) -{ - /* If the branch of the runtime test is taken - i.e. - the vectorized - version is skipped - this incurs a misprediction cost (because the - vectorized version is expected to be the fall-through). So we subtract - the latency of a mispredicted branch from the costs that are incurred - when the vectorized version is executed. */ - if (runtime_test) - return -19; - else - return 0; +spu_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost) +{ + switch (type_of_cost) + { + case scalar_stmt: + case vector_stmt: + case vector_load: + case vector_store: + case vec_to_scalar: + case scalar_to_vec: + case cond_branch_not_taken: + case vec_perm: + return 1; + + case scalar_store: + return 10; + + case scalar_load: + /* Load + rotate. */ + return 2; + + case unaligned_load: + return 2; + + case cond_branch_taken: + return 6; + + default: + gcc_unreachable (); + } } /* Return true iff, data reference of TYPE can reach vector alignment (16) diff --git a/gcc/config/spu/spu.h b/gcc/config/spu/spu.h index c8b0e12..54b4612 100644 --- a/gcc/config/spu/spu.h +++ b/gcc/config/spu/spu.h @@ -524,57 +524,6 @@ targetm.resolve_overloaded_builtin = spu_resolve_overloaded_builtin; \ do { if (LOG!=0) fprintf (FILE, "\t.align\t%d\n", (LOG)); } while (0) -/* Model costs for the vectorizer. */ - -/* Cost of conditional branch. */ -#ifndef TARG_COND_BRANCH_COST -#define TARG_COND_BRANCH_COST 6 -#endif - -/* Cost of any scalar operation, excluding load and store. */ -#ifndef TARG_SCALAR_STMT_COST -#define TARG_SCALAR_STMT_COST 1 -#endif - -/* Cost of scalar load. */ -#undef TARG_SCALAR_LOAD_COST -#define TARG_SCALAR_LOAD_COST 2 /* load + rotate */ - -/* Cost of scalar store. */ -#undef TARG_SCALAR_STORE_COST -#define TARG_SCALAR_STORE_COST 10 - -/* Cost of any vector operation, excluding load, store, - or vector to scalar operation. */ -#undef TARG_VEC_STMT_COST -#define TARG_VEC_STMT_COST 1 - -/* Cost of vector to scalar operation. */ -#undef TARG_VEC_TO_SCALAR_COST -#define TARG_VEC_TO_SCALAR_COST 1 - -/* Cost of scalar to vector operation. */ -#undef TARG_SCALAR_TO_VEC_COST -#define TARG_SCALAR_TO_VEC_COST 1 - -/* Cost of aligned vector load. */ -#undef TARG_VEC_LOAD_COST -#define TARG_VEC_LOAD_COST 1 - -/* Cost of misaligned vector load. */ -#undef TARG_VEC_UNALIGNED_LOAD_COST -#define TARG_VEC_UNALIGNED_LOAD_COST 2 - -/* Cost of vector store. */ -#undef TARG_VEC_STORE_COST -#define TARG_VEC_STORE_COST 1 - -/* Cost of vector permutation. */ -#ifndef TARG_VEC_PERMUTE_COST -#define TARG_VEC_PERMUTE_COST 1 -#endif - - /* Misc */ #define CASE_VECTOR_MODE SImode |