[RFC PATCH, i386]: Autovectorize 8-byte vectors

Uros Bizjak ubizjak@gmail.com
Wed Jun 26 10:19:00 GMT 2019


On Wed, Jun 26, 2019 at 10:47 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Wed, Jun 26, 2019 at 10:17:26AM +0200, Uros Bizjak wrote:
> > Please note that the patch regresses
> >
> > FAIL: gcc.target/i386/sse2-vect-simd-11.c scan-tree-dump-times vect
> > "vectorized [1-3] loops" 2
> > FAIL: gcc.target/i386/sse2-vect-simd-15.c scan-tree-dump-times vect
> > "vectorized [1-3] loops" 2
> >
> > For some reason, the compiler decides to vectorize with 8-byte
> > vectors, resulting in:
> >
> > missed:   not vectorized: relevant stmt not supported: _8 = (short
> > unsigned int) _4;
> > missed:  bad operation or unsupported loop bound.
> > missed: couldn't vectorize loop
> >
> > However, the unpatched compiler is able to vectorize loop using
> > 16-byte vectors. It looks that the compiler should re-run
> > vectorization with wider vectors, if vectorization with narrower
> > vectors fails. Jakub, Richard, do you have any insight in this issue?
> >
> > 2019-06-26  Uroš Bizjak  <ubizjak@gmail.com>
> >
> >         * config/i386/i386.c (ix86_autovectorize_vector_sizes):
> >         Autovectorize 8-byte vectors for TARGET_MMX_WITH_SSE.
>
> The patch isn't correct if TARGET_MMX_WITH_SSE, but not TARGET_AVX, because
> in that case it will push only that 8 and nothing else, while you really
> want to have 16 and 8 in that order, so that it tries to vectorize first
> with 16-byte vectors and fall back to 8-byte.  The hook is supposed to
> either push nothing at all, then only one vector size is tried,
> one derived from preferred_simd_mode, or push all possible vectorization
> sizes to be tried.

Thanks for the explanation and the patch!

Yes, the patch works OK. I'll regression test it and push it later today.

Thanks,
Uros.

> The following patch fixes the failures:
>
> --- gcc/config/i386/i386.c.jj   2019-06-26 09:15:53.474869259 +0200
> +++ gcc/config/i386/i386.c      2019-06-26 10:42:01.354106012 +0200
> @@ -21401,6 +21401,11 @@ ix86_autovectorize_vector_sizes (vector_
>        sizes->safe_push (16);
>        sizes->safe_push (32);
>      }
> +  else if (TARGET_MMX_WITH_SSE)
> +    sizes->safe_push (16);
> +
> +  if (TARGET_MMX_WITH_SSE)
> +    sizes->safe_push (8);
>  }
>
>  /* Implemenation of targetm.vectorize.get_mask_mode.  */
>
>
>         Jakub



More information about the Gcc-patches mailing list