public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110202] New: _mm512_ternarylogic_epi64 generates unnecessary operations
@ 2023-06-10 10:37 fabio at cannizzo dot net
  2023-06-10 16:07 ` [Bug target/110202] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: fabio at cannizzo dot net @ 2023-06-10 10:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110202
           Summary: _mm512_ternarylogic_epi64 generates unnecessary
                    operations
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fabio at cannizzo dot net
  Target Milestone: ---

Consider the following two alternative implementations of a bitwise complement
of an avx512 register.

#include <immintrin.h>

__m512i negate1(const __m512i *a)
{
    __m512i res;
    res = c(res, res, *a, 0x55);
    return res;
}

__m512i negate2(const __m512i *a)
{
    __m512i res;
    res = _mm512_xor_si512(*a, _mm512_set1_epi32(-1));
    return res;
}

which compiled with "-O3 -mavx512f" generates the asm listings (see godbolt:
https://godbolt.org/z/jvrxEjW65)

negate1(long long __vector(8) const*):
        vpxor   xmm0, xmm0, xmm0
        vpternlogq      zmm0, zmm0, ZMMWORD PTR [rdi], 85
        ret
negate2(long long __vector(8) const*):
        vpternlogd      zmm0, zmm0, ZMMWORD PTR [rdi], 0x55
        ret

negate1 introduces an unnecessary xor operation. Probably this is because it
does not recognize that, when vpternlogd is used with code 0x55, it only uses
the third zmm argument.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-08-05 15:32 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-10 10:37 [Bug c++/110202] New: _mm512_ternarylogic_epi64 generates unnecessary operations fabio at cannizzo dot net
2023-06-10 16:07 ` [Bug target/110202] " pinskia at gcc dot gnu.org
2023-06-10 16:14 ` [Bug rtl-optimization/110202] " pinskia at gcc dot gnu.org
2023-06-10 18:36 ` jakub at gcc dot gnu.org
2023-06-10 21:10 ` pinskia at gcc dot gnu.org
2023-06-12 17:14 ` fabio at cannizzo dot net
2023-06-12 19:04 ` amonakov at gcc dot gnu.org
2023-06-27 17:59 ` amonakov at gcc dot gnu.org
2023-06-28  0:47 ` crazylht at gmail dot com
2023-06-28  5:07 ` amonakov at gcc dot gnu.org
2023-07-12  7:51 ` cvs-commit at gcc dot gnu.org
2023-08-04 16:44 ` [Bug target/110202] " cvs-commit at gcc dot gnu.org
2023-08-05 15:32 ` amonakov at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).