From e8f142e28262a5048c6f40f4bfb6a612d3da55f0 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Thu, 14 Sep 2017 16:30:36 +0000 Subject: Add a vect_get_num_copies helper routine This patch adds a vectoriser helper routine to calculate how many copies of a vector statement we need. At present this is always: LOOP_VINFO_VECT_FACTOR (loop_vinfo) / TYPE_VECTOR_SUBPARTS (vectype) but later patches add other cases. Another benefit of using a helper routine is that it can assert that the division is exact (which it must be). 2017-09-14 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree-vectorizer.h (vect_get_num_copies): New function. * tree-vect-data-refs.c (vect_get_data_access_cost): Use it. * tree-vect-loop.c (vectorizable_reduction): Likewise. (vectorizable_induction): Likewise. (vectorizable_live_operation): Likewise. * tree-vect-stmts.c (vectorizable_mask_load_store): Likewise. (vectorizable_bswap): Likewise. (vectorizable_call): Likewise. (vectorizable_conversion): Likewise. (vectorizable_assignment): Likewise. (vectorizable_shift): Likewise. (vectorizable_operation): Likewise. (vectorizable_store): Likewise. (vectorizable_load): Likewise. (vectorizable_condition): Likewise. (vectorizable_comparison): Likewise. (vect_analyze_stmt): Pass the slp node to vectorizable_live_operation. Co-Authored-By: Alan Hayward Co-Authored-By: David Sherwood From-SVN: r252764 --- gcc/tree-vectorizer.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gcc/tree-vectorizer.h') diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 7ed0078..6efcd51 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -1076,6 +1076,20 @@ unlimited_cost_model (loop_p loop) return (flag_vect_cost_model == VECT_COST_MODEL_UNLIMITED); } +/* Return the number of copies needed for loop vectorization when + a statement operates on vectors of type VECTYPE. This is the + vectorization factor divided by the number of elements in + VECTYPE and is always known at compile time. */ + +static inline unsigned int +vect_get_num_copies (loop_vec_info loop_vinfo, tree vectype) +{ + gcc_checking_assert (LOOP_VINFO_VECT_FACTOR (loop_vinfo) + % TYPE_VECTOR_SUBPARTS (vectype) == 0); + return (LOOP_VINFO_VECT_FACTOR (loop_vinfo) + / TYPE_VECTOR_SUBPARTS (vectype)); +} + /* Source location */ extern source_location vect_location; -- cgit v1.1