[patch, vectorizer] Handle pattern statements with multiple uses

Richard Guenther richard.guenther@gmail.com
Wed Jun 29 11:29:00 GMT 2011


On Wed, Jun 29, 2011 at 8:31 AM, Ira Rosen <ira.rosen@linaro.org> wrote:
> Hi,
>
> This is a follow-up patch for
> http://gcc.gnu.org/ml/gcc-patches/2011-06/msg01205.html.
> The previous patch added a support for widen-mult in intermediate type, e.g.,:
>
>     char a_t;
>     short a_it;
>     int a_T, prod_T,  prod_T';
>
>     S1  a_t = ;
>     S3  a_T = (int) a_t;
>           '--> a_it = (short) a_t;
>     S5  prod_T = a_T * CONST;
>           '--> prod_T' = a_it w* CONST;
>
>
> This way we create a patten stmt a_it = (short) a_t; (used in the
> pattern) to replace the original a_T = (int) a_t;, which prevents
> vectorization if there are other uses of a_T outside the pattern,
> e.g.,
>
>    char a_t;
>     short a_it;
>     int a_T, prod_T,  prod_T', x_T, y_T;
>
>     S1  a_t = ;
>     S3  a_T = (int) a_t;
>           '--> a_it = (short) a_t;
>     S5  prod_T = a_T * CONST;
>           '--> prod_T' = a_it w* CONST;
>     S6 x_T = a_T + y_T;
>
> Here the addition (S6) should be performed on int and use the original
> definition.
> Currently the vectorization fails on the type check of this statement.
>
> This patch adds a support of such cases: we mark the original
> statement as relevant for vectorization (and not only its related
> pattern statement) and handle both the original and pattern statements
> in the analysis and the transformation.
>
> Bootstrapped and tested on powerpc64-suse-linux.
> Comments are welcome.

Looks reasonable to me.

Thanks,
Richard.

> Thanks,
> Ira
>
> ChangeLog:
>
>   * tree-vect-loop.c (vect_determine_vectorization_factor): Handle
>   both pattern and original statements if necessary.
>   (vect_transform_loop): Likewise.
>    * tree-vect-patterns.c (vect_pattern_recog): Update documentation.
>    * tree-vect-stmts.c (vect_mark_relevant): Add new argument.
>   Mark the pattern statement only if the original statement doesn't
>   have its own uses.
>   (process_use): Call vect_mark_relevant with additional parameter.
>   (vect_mark_stmts_to_be_vectorized): Likewise.
>   (vect_get_vec_def_for_operand): Use vectorized pattern statement.
>   (vect_analyze_stmt): Handle both pattern and original statements
>   if necessary.
>   (vect_transform_stmt): Don't store vectorized pattern statement
>   in the original statement.
>   (vect_is_simple_use_1): Use related pattern statement only if the
>   original statement is irrelevant.
>   * tree-vect-slp.c (vect_get_and_check_slp_defs): Likewise.
>
> testsuite/ChangeLog:
>   * gcc.dg/vect/slp-widen-mult-half.c: New test.
>   * gcc.dg/vect/vect-widen-mult-half.c: New test.
>



More information about the Gcc-patches mailing list