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, vectorizer] Fix PR tree-optimization/33804 ICE in vect_transform_stmt


On 10/24/07, Ira Rosen <IRAR@il.ibm.com> wrote:
>
> Hi,
>
> The check whether the vectorization is worthwhile, in case that the
> operation is not supported by the target, is performed in function
> vectorizable_operation, both during the analysis and the transformation.
> The check is based on the loop vectorization factor. We put gcc_assert to
> verify that it does not fail during the transformation phase, since the
> decision whether to vectorize should be made during the analysis.
>
> The testcase in PR 33804 ICEs, because the vectorization factor was changed
> at the end of the analysis, and its comparison with
> vect_min_worthwhile_factor gives different results during the analysis and
> the transformation.
>
> This patch removes the check that the vectorization is worthwhile from the
> transformation phase: the vectorization factor can get smaller only in case
> that there is only SLP-kind of vectorization in the loop, and the VF is the
> unrolling factor needed to operate on full vectors. So the profitability of
> the loop vectorization cannot actually change after the analysis.
>
> Bootstrapped with vectorization enabled and now regtesting on x86_64-linux.
> O.K. for mainline once the testing completes?

Yes.  Thanks,

Richard.

> Thanks,
> Ira
>
> ChangeLog:
>
>       PR tree-optimization/33804
>       * tree-vect-transform.c (vectorizable_operation): Remove the
>       checks that the vectorization is worthwhile from the transformation
>       phase.
>
> testsuite/ChangeLog:
>
>       PR tree-optimization/33804
>       * gcc.dg/vect/pr33804.c: New testcase.
>
>
> Index: tree-vect-transform.c
> ===================================================================
> --- tree-vect-transform.c       (revision 129577)
> +++ tree-vect-transform.c       (working copy)
> @@ -3825,18 +3825,21 @@ vectorizable_operation (tree stmt, block
>      {
>        if (vect_print_dump_info (REPORT_DETAILS))
>         fprintf (vect_dump, "op not supported by target.");
> +      /* Check only during analysis.  */
>        if (GET_MODE_SIZE (vec_mode) != UNITS_PER_WORD
> -          || LOOP_VINFO_VECT_FACTOR (loop_vinfo)
> -            < vect_min_worthwhile_factor (code))
> +          || (LOOP_VINFO_VECT_FACTOR (loop_vinfo)
> +             < vect_min_worthwhile_factor (code)
> +             && !vec_stmt))
>          return false;
>        if (vect_print_dump_info (REPORT_DETAILS))
>         fprintf (vect_dump, "proceeding using word mode.");
>      }
>
> -  /* Worthwhile without SIMD support?  */
> +  /* Worthwhile without SIMD support? Check only during analysis.  */
>    if (!VECTOR_MODE_P (TYPE_MODE (vectype))
>        && LOOP_VINFO_VECT_FACTOR (loop_vinfo)
> -        < vect_min_worthwhile_factor (code))
> +        < vect_min_worthwhile_factor (code)
> +      && !vec_stmt)
>      {
>        if (vect_print_dump_info (REPORT_DETAILS))
>         fprintf (vect_dump, "not worthwhile without SIMD support.");
> Index: testsuite/gcc.dg/vect/pr33804.c
> ===================================================================
> --- testsuite/gcc.dg/vect/pr33804.c     (revision 0)
> +++ testsuite/gcc.dg/vect/pr33804.c     (revision 0)
> @@ -0,0 +1,17 @@
> +/* { dg-do compile } */
> +/* { dg-require-effective-target vect_int } */
> +
> +void f(unsigned char *s, unsigned char *d, int n) {
> +    int i;
> +    for (i = 0; i < n; i += 4) {
> +        d[i + 0] += s[i + 0];
> +        d[i + 1] += s[i + 1];
> +        d[i + 2] += s[i + 2];
> +        d[i + 3] += s[i + 3];
> +    }
> +}
> +
> +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  } } */
> +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1
> "vect"  } } */
> +/* { dg-final { cleanup-tree-dump "vect" } } */
> +
>
>


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