Use loop->safelen rather than loop->force_vectorize

Richard Biener richard.guenther@gmail.com
Fri Mar 2 08:22:00 GMT 2018


On Thu, Mar 1, 2018 at 7:20 PM, Richard Sandiford
<richard.sandiford@linaro.org> wrote:
> ...since the latter doesn't guarantee independence by itself.
>
> Tested on aarch64-linux-gnu.  OK to install?

Ok.

Richard.

> Richard
>
>
> 2018-03-01  Richard Sandiford  <richard.sandiford@linaro.org>
>
> gcc/
>         * tree-vect-data-refs.c (vect_analyze_data_ref_dependence)
>         (vect_analyze_data_ref_access): Use loop->safe_len rather than
>         loop->force_vectorize to check whether there is no alias.
>
> gcc/testsuite/
>         * gcc.dg/vect/vect-alias-check-13.c: New test.
>
> Index: gcc/tree-vect-data-refs.c
> ===================================================================
> --- gcc/tree-vect-data-refs.c   2018-02-10 09:49:47.950776097 +0000
> +++ gcc/tree-vect-data-refs.c   2018-03-01 18:17:41.631482331 +0000
> @@ -466,7 +466,7 @@ vect_analyze_data_ref_dependence (struct
>               return true;
>             }
>
> -         if (!loop->force_vectorize)
> +         if (loop->safelen < 2)
>             {
>               tree indicator = dr_zero_step_indicator (dra);
>               if (TREE_CODE (indicator) != INTEGER_CST)
> @@ -2720,7 +2720,7 @@ vect_analyze_data_ref_access (struct dat
>        /* Allow references with zero step for outer loops marked
>          with pragma omp simd only - it guarantees absence of
>          loop-carried dependencies between inner loop iterations.  */
> -      if (!loop->force_vectorize)
> +      if (loop->safelen < 2)
>         {
>           if (dump_enabled_p ())
>             dump_printf_loc (MSG_NOTE, vect_location,
> Index: gcc/testsuite/gcc.dg/vect/vect-alias-check-13.c
> ===================================================================
> --- /dev/null   2018-03-01 08:17:49.562264353 +0000
> +++ gcc/testsuite/gcc.dg/vect/vect-alias-check-13.c     2018-03-01 18:17:41.630484279 +0000
> @@ -0,0 +1,21 @@
> +/* { dg-do compile } */
> +/* { dg-require-effective-target vect_int } */
> +
> +void
> +f1 (int *x, long step1, int n)
> +{
> +  for (int i = 0; i < n; ++i)
> +    x[i * step1] += 1;
> +}
> +
> +void
> +f2 (int *x, long step2, int n)
> +{
> +#pragma GCC ivdep
> +  for (int i = 0; i < n; ++i)
> +    x[i * step2] += 2;
> +}
> +
> +/* { dg-final { scan-tree-dump {need run-time check that [^\n]*step1[^\n]* is nonzero} "vect" } } */
> +/* { dg-final { scan-tree-dump-not {need run-time check that [^\n]*step2[^\n]* is nonzero} "vect" } } */
> +/* { dg-final { scan-tree-dump-times {LOOP VECTORIZED} 2 "vect" } } */



More information about the Gcc-patches mailing list