This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Reduce over-promotion of vector operations


On Thu, Aug 4, 2011 at 9:47 AM, Ira Rosen <ira.rosen@linaro.org> wrote:
> On 19 July 2011 09:44, Ira Rosen <ira.rosen@linaro.org> wrote:
>> Hi,
>>
>> This patch tries to reduce over-promotion of vector operations that
>> could be done with narrower elements, e.g., for
>>
>> char a;
>> int b, c;
>> short d;
>>
>> b = (int) a;
>> c = b << 2;
>> d = (short) c;
>>
>> we currently produce six vec_unpack_lo/hi_expr statements for
>> char->int conversion and then two vec_pack_trunc_expr for short->int.
>> While the shift can be performed on short, using only two
>> vec_unpack_lo/hi_expr operations for char->short conversion in this
>> example.
>>
>> With this patch we detect such over-promoted sequences that start with
>> a type promotion operation and end with a type demotion operation. The
>> statements in between are checked if they can be performed using
>> smaller type (this patch only adds a support for shifts and bit
>> operations with a constant). If a sequence is detected we create a
>> sequence of scalar pattern statements to be vectorized instead the
>> original one. ?Since there may be two pattern statements created for
>> the same original statement - the operation itself (on an intermediate
>> type) and a type promotion (from a smaller type to the intermediate
>> type) for the non-constant operand - this patch adds a new field to
>> struct _stmt_vec_info to keep that pattern def statement.
>>
>> Bootstrapped and tested on powerpc64-suse-linux.
>> Comments are welcome.
>
> I committed the attached version which incorporates Richard's comments
> from here http://gcc.gnu.org/ml/gcc-patches/2011-08/msg00144.html.
>
> Thanks,
> Ira
>
>>
>> Thanks,
>> Ira
>>
>> ChangeLog:
>>
>> ? * tree-vectorizer.h (struct _stmt_vec_info): Add new field for
>> ? pattern def statement, and its access macro.
>> ? (NUM_PATTERNS): Set to 5.
>> ? * tree-vect-loop.c (vect_determine_vectorization_factor): Handle
>> ? pattern def statement.
>> ? (vect_transform_loop): Likewise.
>> ? * tree-vect-patterns.c (vect_vect_recog_func_ptrs): Add new
>> ? function vect_recog_over_widening_pattern ().
>> ? (vect_operation_fits_smaller_type): New function.
>> ? (vect_recog_over_widening_pattern, vect_mark_pattern_stmts):
>> ? Likewise.
>> ? (vect_pattern_recog_1): Move the code that marks pattern
>> ? statements to vect_mark_pattern_stmts (), and call it. ?Update
>> ? documentation.
>> ? * tree-vect-stmts.c (vect_supportable_shift): New function.
>> ? (vect_analyze_stmt): Handle pattern def statement.
>> ? (new_stmt_vec_info): Initialize pattern def statement.

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53693

-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]