[PATCH] [i386] Optimize __builtin_shuffle_vector.

Hongtao Liu crazylht@gmail.com
Tue Aug 17 01:45:52 GMT 2021


On Mon, Aug 16, 2021 at 3:25 PM Hongtao Liu <crazylht@gmail.com> wrote:
>
> On Mon, Aug 16, 2021 at 3:11 PM Jakub Jelinek via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
> >
> > On Mon, Aug 16, 2021 at 01:18:38PM +0800, liuhongt via Gcc-patches wrote:
> > > +  /* Accept VNxHImode and VNxQImode now.  */
> > > +  if (!TARGET_AVX512VL && GET_MODE_SIZE (mode) < 64)
> > > +    return false;
> > > +
> > > +  /* vpermw.  */
> > > +  if (!TARGET_AVX512BW && inner_size == 2)
> > > +    return false;
> > > +
> > > +  /* vpermb.   */
> >
> > Too many spaces after dot.
> >
> > > @@ -18301,7 +18380,7 @@ expand_vec_perm_1 (struct expand_vec_perm_d *d)
> > >    if (expand_vec_perm_palignr (d, true))
> > >      return true;
> > >
> > > -  /* Try the AVX512F vperm{s,d} instructions.  */
> > > +  /* Try the AVX512F vperm{w,b,s,d} and instructions  */
> >
> > What is the " and" doing there?
> Typo.
> >
> > > +  /* Check that the permutation is suitable for pmovz{bw,wd,dq}.
> > > +     For example V16HImode to V8HImode
> > > +     { 0 2 4 6 8 10 12 14 * * * * * * * * }.  */
> > > +  for (int i = 0; i != nelt/2; i++)
> >
> > nelt / 2 please
> >
> > Otherwise LGTM.
> >
> Thanks for the review.
> >         Jakub
> >
>
>
> --
> BR,
> Hongtao

This patch caused FAIL: gcc.target/i386/pr82460-2.c scan-assembler-not
\\mvpermi2b\\M with -march=cascadelake

So adjust the testcase with the following patch.

    [i386] Adjust testcase.

    This testcase is used to detect reuse of perm mask in the main loop,
    in epilog, vpermi2b can still be used, so add the option
    --param=vect-epilogues-nomask=0.

    gcc/testsuite/ChangeLog:

            * gcc.target/i386/pr82460-2.c: Adjust testcase by adding
            --param=vect-epilogues-nomask=0

diff --git a/gcc/testsuite/gcc.target/i386/pr82460-2.c
b/gcc/testsuite/gcc.target/i386/pr82460-2.c
index 4a45beed715..8cdfb54f56a 100644
--- a/gcc/testsuite/gcc.target/i386/pr82460-2.c
+++ b/gcc/testsuite/gcc.target/i386/pr82460-2.c
@@ -1,6 +1,6 @@
 /* PR target/82460 */
 /* { dg-do compile } */
-/* { dg-options "-O2 -ftree-vectorize -mavx512vbmi
-mprefer-vector-width=none" } */
+/* { dg-options "-O2 -ftree-vectorize -mavx512vbmi
-mprefer-vector-width=none --param=vect-epilogues-nomask=0" } */
 /* We want to reuse the permutation mask in the loop, so use vpermt2b rather
    than vpermi2b.  */
 /* { dg-final { scan-assembler-not {\mvpermi2b\M} } } */


--
BR,
Hongtao


More information about the Gcc-patches mailing list