Jakub Jelinek <ja...@redhat.com> writes:

> Hi!
>
> This testcase used to be vectorized before r260348, but isn't any longer.
> The problem is that while we check with types_compatible_p:
>       /* We can only handle calls with arguments of the same type.  */
>       if (rhs_type
>           && !types_compatible_p (rhs_type, TREE_TYPE (op)))
> we required pointer equality for the corresponding vectypes, which isn't
> true on the testcase, where two arguments are const float and have const
> vector of float vectype, while the last one is float and has vector of float
> vectype.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk and 9.3 after a while?
>
> 2019-09-11  Jakub Jelinek  <ja...@redhat.com>
>
>       PR tree-optimization/91723
>       * tree-vect-stmts.c (vectorizable_call): Use types_compatible_p check
>       instead of pointer equality when checking if argument vectypes are
>       the same.
>
>       * gcc.dg/vect/vect-fma-3.c: New test.

OK, thanks.

Richard

> --- gcc/tree-vect-stmts.c.jj  2019-08-27 23:01:31.000000000 +0200
> +++ gcc/tree-vect-stmts.c     2019-09-10 20:28:18.646389500 +0200
> @@ -3308,7 +3308,7 @@ vectorizable_call (stmt_vec_info stmt_in
>        if (!vectype_in)
>       vectype_in = vectypes[i];
>        else if (vectypes[i]
> -            && vectypes[i] != vectype_in)
> +            && !types_compatible_p (vectypes[i], vectype_in))
>       {
>         if (dump_enabled_p ())
>           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
> --- gcc/testsuite/gcc.dg/vect/vect-fma-3.c.jj 2019-09-10 20:39:57.219889700 
> +0200
> +++ gcc/testsuite/gcc.dg/vect/vect-fma-3.c    2019-09-10 20:44:11.297055814 
> +0200
> @@ -0,0 +1,17 @@
> +/* PR tree-optimization/91723 */
> +/* { dg-do compile { target { scalar_all_fma || { i?86-*-* x86_64-*-* } } } 
> } */
> +/* { dg-additional-options "-mfma" { target { i?86-*-* x86_64-*-* } } } */
> +
> +void
> +foo (double *restrict r, const double *restrict a,
> +     const double *restrict b, const double *restrict c)
> +{
> +  for (int i = 0; i < 1024; i++)
> +    {
> +      double x = __builtin_fma (a[i], b[i], c[i]);
> +      x = __builtin_fma (a[i], b[i], x);
> +      r[i] = x;
> +    }
> +}
> +
> +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 1 "vect" { target 
> vect_double } } } */
>
>       Jakub

Reply via email to