[Bug target/93696] AVX512VPOPCNTDQ writemask intrinsics produce incorrect results

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Feb 13 22:34:00 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93696

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:08cf145f991327d943d785066709f5f39d20bd85

commit r9-8226-g08cf145f991327d943d785066709f5f39d20bd85
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Feb 13 10:43:27 2020 +0100

    i386: Fix up _mm*_mask_popcnt_epi* [PR93696]

    As mentioned in the PR and as
   
https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mask_popcnt_epi
    also documents, _mm*_popcnt_epi* intrinsics are consistent with all other
    unary AVX512* intrinsics regarding arguments, i.e. the
    _mm*_whatever has just single argument (called a in the docs, and __A in
the
    GCC headers),
    _mm*_mask_whatever has 3 arguments (called src, k, a in the docs and
    _W, __U, __A in GCC headers) and
    _mm*_maskz_whatever 2 arguments (called k, a in the docs and __U, __A in
GCC
    headers).  Unfortunately, whomever implemented the _mm*_popcnt_epi*
    intrinsics got it wrong for the _mm*_mask_popcnt_epi* ones, calling the
    args __A, __U, __B and not passing them in the canonical order to the
    builtins, making it API incompatible with ICC as well as clang (tested on
    godbolts clang 7/8/9/trunk and ICC 19.0.{0,1}, older clang/ICC don't
    understand those, so it isn't that it used to be broken even in other
    compilers and got changed afterwards).

    2020-02-13  Jakub Jelinek  <jakub@redhat.com>

        PR target/93696
        * config/i386/avx512bitalgintrin.h (_mm512_mask_popcnt_epi8,
        _mm512_mask_popcnt_epi16, _mm256_mask_popcnt_epi8,
        _mm256_mask_popcnt_epi16, _mm_mask_popcnt_epi8,
        _mm_mask_popcnt_epi16): Rename __B argument to __A and __A to __W,
        pass __A to the builtin followed by __W instead of __A followed by
        __B.
        * config/i386/avx512vpopcntdqintrin.h (_mm512_mask_popcnt_epi32,
        _mm512_mask_popcnt_epi64): Likewise.
        * config/i386/avx512vpopcntdqvlintrin.h (_mm_mask_popcnt_epi32,
        _mm256_mask_popcnt_epi32, _mm_mask_popcnt_epi64,
        _mm256_mask_popcnt_epi64): Likewise.

        * gcc.target/i386/pr93696-1.c: New test.
        * gcc.target/i386/pr93696-2.c: New test.
        * gcc.target/i386/avx512bitalg-vpopcntw-1.c (TEST): Fix argument order
        of _mm*_mask_popcnt_*.
        * gcc.target/i386/avx512vpopcntdq-vpopcntq-1.c (TEST): Likewise.
        * gcc.target/i386/avx512vpopcntdq-vpopcntd-1.c (TEST): Likewise.
        * gcc.target/i386/avx512bitalg-vpopcntb-1.c (TEST): Likewise.
        * gcc.target/i386/avx512bitalg-vpopcntb.c (foo): Likewise.
        * gcc.target/i386/avx512bitalg-vpopcntbvl.c (foo): Likewise.
        * gcc.target/i386/avx512vpopcntdq-vpopcntd.c (foo): Likewise.
        * gcc.target/i386/avx512bitalg-vpopcntwvl.c (foo): Likewise.
        * gcc.target/i386/avx512bitalg-vpopcntw.c (foo): Likewise.
        * gcc.target/i386/avx512vpopcntdq-vpopcntq.c (foo): Likewise.


More information about the Gcc-bugs mailing list