diff options
author | Dorit Nuzman <dorit@il.ibm.com> | 2007-07-12 12:17:03 +0000 |
---|---|---|
committer | Dorit Nuzman <dorit@gcc.gnu.org> | 2007-07-12 12:17:03 +0000 |
commit | e95b59d2abbeea533bfcea315ed2b47412f21470 (patch) | |
tree | 85414467a7c6b6b6755c5dbe54511f8981c7db54 /gcc/config | |
parent | e1c8221962aa8dfba5b2462449bccfe10c2d561e (diff) | |
download | gcc-e95b59d2abbeea533bfcea315ed2b47412f21470.zip gcc-e95b59d2abbeea533bfcea315ed2b47412f21470.tar.gz gcc-e95b59d2abbeea533bfcea315ed2b47412f21470.tar.bz2 |
target.h (builtin_vectorization_cost): Add new target builtin.
2007-07-12 Dorit Nuzman <dorit@il.ibm.com>
* target.h (builtin_vectorization_cost): Add new target builtin.
* target-def.h (TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST): New.
* tree-vectorizer.h (TARG_SCALAR_STMT_COST): New.
(TARG_SCALAR_LOAD_COST, TARG_SCALAR_STORE_COST): New.
* tree-vect-analyze.c (vect_analyze_slp_instance): Initisliaze
uninitialized variables.
* tree-vect-transform.c (cost_for_stmt): New function.
(vect_estimate_min_profitable_iters): Call cost_for_stmt instead of
using cost 1 for all scalar stmts. Be less conservative when
estimating the number of prologue/epulogue iterations. Call
targetm.vectorize.builtin_vectorization_cost. Return
min_profitable_iters-1.
(vect_model_reduction_cost): Use TARG_SCALAR_TO_VEC_COST for
initialization cost instead of TARG_VEC_STMT_COST. Use
TARG_VEC_TO_SCALAR_COST instead of TARG_VEC_STMT_COST for reduction
epilogue code. Fix epilogue cost computation.
* config/spu/spu.c (spu_builtin_vectorization_cost): New.
(TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST): Implement.
* config/spu/spu.h (TARG_COND_BRANCH_COST, TARG_SCALAR_STMT_COST):
(TARG_SCALAR_LOAD_COST, TARG_SCALAR_STORE_COST, TARG_VEC_STMT_COST):
(TARG_VEC_TO_SCALAR_COST, TARG_SCALAR_TO_VEC, TARG_VEC_LOAD_COST):
(TARG_VEC_UNALIGNED_LOAD_COST, TARG_VEC_STORE_COST): Define.
2007-07-12 Dorit Nuzman <dorit@il.ibm.com>
* gcc.dg/vect/costmodel/ppc/costmodel-vect-reduc-1char.c: Loops now
get vectorized.
* gcc.dg/vect/costmodel/i386/costmodel-vect-reduc-1char.c: Loops
now get vectorized.
* gcc.dg/vect/costmodel/spu/spu-costmodel-vect.exp: New.
* gcc.dg/vect/costmodel/spu/costmodel-fast-math-vect-pr29925.c: New.
* gcc.dg/vect/costmodel/spu/costmodel-vect-31a.c: New.
* gcc.dg/vect/costmodel/spu/costmodel-vect-31b.c: New.
* gcc.dg/vect/costmodel/spu/costmodel-vect-31c.c: New.
* gcc.dg/vect/costmodel/spu/costmodel-vect-31d.c: New.
* gcc.dg/vect/costmodel/spu/costmodel-vect-iv-9.c: New.
* gcc.dg/vect/costmodel/spu/costmodel-vect-33.c: New.
* gcc.dg/vect/costmodel/spu/costmodel-vect-76a.c: New.
* gcc.dg/vect/costmodel/spu/costmodel-vect-76b.c: New.
* gcc.dg/vect/costmodel/spu/costmodel-vect-76c.c: New.
* gcc.dg/vect/costmodel/spu/costmodel-vect-68a.c: New.
* gcc.dg/vect/costmodel/spu/costmodel-vect-68b.c: New.
* gcc.dg/vect/costmodel/spu/costmodel-vect-68c.c: New.
* gcc.dg/vect/costmodel/spu/costmodel-vect-68d.c: New.
* lib/target-supports.exp (check_effective_target_vect_int_mul):
Add spu.
From-SVN: r126584
Diffstat (limited to 'gcc/config')
-rw-r--r-- | gcc/config/spu/spu.c | 19 | ||||
-rw-r--r-- | gcc/config/spu/spu.h | 46 |
2 files changed, 65 insertions, 0 deletions
diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c index 7e28167..f963268 100644 --- a/gcc/config/spu/spu.c +++ b/gcc/config/spu/spu.c @@ -133,6 +133,7 @@ static void spu_encode_section_info (tree, rtx, int); 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); extern const char *reg_names[]; rtx spu_compare_op0, spu_compare_op1; @@ -261,6 +262,9 @@ const struct attribute_spec spu_attribute_table[]; #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD spu_builtin_mask_for_load +#undef TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST +#define TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST spu_builtin_vectorization_cost + struct gcc_target targetm = TARGET_INITIALIZER; void @@ -5191,6 +5195,21 @@ spu_builtin_mask_for_load (void) return d->fndecl; } +/* 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 incured + when the vectorized version is executed. */ + if (runtime_test) + return -19; + else + return 0; +} + void spu_init_expanders (void) { diff --git a/gcc/config/spu/spu.h b/gcc/config/spu/spu.h index 1f15472..b8af6b2 100644 --- a/gcc/config/spu/spu.h +++ b/gcc/config/spu/spu.h @@ -542,6 +542,52 @@ 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 + + /* Misc */ #define CASE_VECTOR_MODE SImode |