Add a vect_get_num_copies helper routine
Richard Sandiford
richard.sandiford@linaro.org
Sat Sep 16 20:42:00 GMT 2017
"H.J. Lu" <hjl.tools@gmail.com> writes:
> On Thu, Sep 14, 2017 at 4:22 AM, Richard Sandiford
> <richard.sandiford@linaro.org> wrote:
>> 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).
>>
>> Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu.
>> OK to install?
>>
>> Richard
>>
>>
>> 2017-09-14 Richard Sandiford <richard.sandiford@linaro.org>
>> Alan Hayward <alan.hayward@arm.com>
>> David Sherwood <david.sherwood@arm.com>
>>
>> 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.
>>
>> Index: gcc/tree-vectorizer.h
>> ===================================================================
>> --- gcc/tree-vectorizer.h 2017-09-14 11:25:32.166167193 +0100
>> +++ gcc/tree-vectorizer.h 2017-09-14 11:27:50.352072753 +0100
>> @@ -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;
>>
>
> I believe this caused:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82228
Yeah, it did, sorry. I've just committed a fix.
Thanks,
Richard
More information about the Gcc-patches
mailing list