]> git.ipfire.org Git - thirdparty/gcc.git/commit
i386: Fix V{64QI,32HI}mode constant permutations [PR94509]
authorJakub Jelinek <jakub@redhat.com>
Tue, 7 Apr 2020 12:39:24 +0000 (14:39 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 7 Apr 2020 12:39:24 +0000 (14:39 +0200)
commitd51af82b4cf4c95c4a7451df2180cc6ebb44856b
tree83cf14d47f41bf298b86f5e1d8960ede45a9ee9d
parent4df50a059fbd4d4a1cb067bd43caccdfca0327a8
i386: Fix V{64QI,32HI}mode constant permutations [PR94509]

The following testcases are miscompiled, because expand_vec_perm_pshufb
incorrectly thinks it can use vpshufb instruction for the permutations
when it can't.
The
          if (vmode == V32QImode)
            {
              /* vpshufb only works intra lanes, it is not
                 possible to shuffle bytes in between the lanes.  */
              for (i = 0; i < nelt; ++i)
                if ((d->perm[i] ^ i) & (nelt / 2))
                  return false;
            }
intra-lane check which is correct has been copied and adjusted for 64-byte
modes into:
          if (vmode == V64QImode)
            {
              /* vpshufb only works intra lanes, it is not
                 possible to shuffle bytes in between the lanes.  */
              for (i = 0; i < nelt; ++i)
                if ((d->perm[i] ^ i) & (nelt / 4))
                  return false;
            }
which is not correct, because 64-byte modes have 4 lanes rather than just
two and the above is only testing that the permutation grabs even lane elts
from even lanes and odd lane elts from odd lanes, but not that they are
from the same 256-bit half.

The following patch fixes it by using 3 * nelt / 4 instead of nelt / 4,
so we actually check the most significant 2 bits rather than just one.

2020-04-07  Jakub Jelinek  <jakub@redhat.com>

PR target/94509
* config/i386/i386-expand.c (expand_vec_perm_pshufb): Fix the check
for inter-lane permutation for 64-byte modes.

* gcc.target/i386/avx512bw-pr94509-1.c: New test.
* gcc.target/i386/avx512bw-pr94509-2.c: New test.
gcc/ChangeLog
gcc/config/i386/i386-expand.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/avx512bw-pr94509-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512bw-pr94509-2.c [new file with mode: 0644]