[patch] Improve detection of widening multiplication in the vectorizer
H.J. Lu
hjl.tools@gmail.com
Tue Jun 7 21:08:00 GMT 2011
On Wed, Jun 1, 2011 at 2:23 AM, Ira Rosen <ira.rosen@linaro.org> wrote:
> Hi,
>
> The vectorizer expects widening multiplication pattern to be:
>
> type a_t, b_t;
> TYPE a_T, b_T, prod_T;
>
> a_T = (TYPE) a_t;
> b_T = (TYPE) b_t;
> prod_T = a_T * b_T;
>
> where type 'TYPE' is double the size of type 'type'. This works fine
> when the types are signed. For the unsigned types the code looks like:
>
> unsigned type a_t, b_t;
> unsigned TYPE u_prod_T;
> TYPE a_T, b_T, prod_T;
>
> a_T = (TYPE) a_t;
> b_T = (TYPE) b_t;
> prod_T = a_T * b_T;
> u_prod_T = (unsigned TYPE) prod_T;
>
> i.e., the multiplication is done on signed, followed by a cast to unsigned.
> This patch adds a support of such patterns and generates
> WIDEN_MULT_EXPR for the unsigned type.
>
> Another unsupported case is multiplication by a constant (e.g., b_T is
> a constant). This patch checks that the constant fits the smaller type
> 'type' and recognizes such cases as widening multiplication.
>
> Bootstrapped and tested on powerpc64-suse-linux. Tested the
> vectorization testsuite on arm-linux-gnueabi.
> I'll commit the patch shortly if there are no comments/objections.
>
> Ira
>
> ChangeLog:
>
> * tree-vectorizer.h (vect_recog_func_ptr): Make last argument to be
> a pointer.
> * tree-vect-patterns.c (vect_recog_widen_sum_pattern,
> vect_recog_widen_mult_pattern, vect_recog_dot_prod_pattern,
> vect_recog_pow_pattern): Likewise.
> (vect_pattern_recog_1): Remove declaration.
> (widened_name_p): Remove declaration. Add new argument to specify
> whether to check that both types are either signed or unsigned.
> (vect_recog_widen_mult_pattern): Update documentation. Handle
> unsigned patterns and multiplication by constants.
> (vect_pattern_recog_1): Update vect_recog_func references. Use
> statement information from the statement returned from pattern
> detection functions.
> (vect_pattern_recog): Update vect_recog_func reference.
> * tree-vect-stmts.c (vectorizable_type_promotion): For widening
> multiplication by a constant use the type of the other operand.
>
.
This caused:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49318
--
H.J.
More information about the Gcc-patches
mailing list