public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/101021] New: PSHUFB is emitted instead of PSHUFD, PSHUFLW and PSHUFHW with -msse4
Date: Thu, 10 Jun 2021 18:07:14 +0000	[thread overview]
Message-ID: <bug-101021-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 101021
           Summary: PSHUFB is emitted instead of PSHUFD, PSHUFLW and
                    PSHUFHW with -msse4
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ubizjak at gmail dot com
  Target Milestone: ---

Following testcase:

--cut here--
typedef char S;
typedef S VV __attribute__((vector_size(16 * sizeof(S))));

VV ref_perm_pshufd (VV x, VV y)
{
  return __builtin_shuffle (x, y, (VV) { 8,9,10,11, 8,9,10,11, 8,9,10,11,
12,13,14,15 });
}

VV ref_perm_pshuflw (VV x)
{
  return __builtin_shuffle (x, (VV) { 0,1, 2,3, 2,3, 6,7, 8,9,10,11,12,13,14,15
});
}

VV ref_perm_pshufhw (VV x)
{
  return __builtin_shuffle (x, (VV) { 0,1,2,3,4,5,6,7, 8,9, 10,11, 10,11, 14,15
});
--cut here--

compiles with -O2 -msse2 to:

<ref_perm_pshufd>:

     pshufd $0xea,%xmm0,%xmm0
     retq   

<ref_perm_pshuflw>:

     pshuflw $0xd4,%xmm0,%xmm0
     retq   

<ref_perm_pshufhw>:

     pshufhw $0xd4,%xmm0,%xmm0
     retq   

Using -msse4 (or higher ISA), the compiler is too eager to emit less optimal
PSHUFB:

<ref_perm_pshufd>:

     pshufb 0x0(%rip),%xmm0
     retq   

<ref_perm_pshuflw>:

     pshufb 0x0(%rip),%xmm0
     retq   

<ref_perm_pshufhw>:

     pshufb 0x0(%rip),%xmm0
     retq

             reply	other threads:[~2021-06-10 18:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-10 18:07 ubizjak at gmail dot com [this message]
2021-06-11  7:35 ` [Bug target/101021] " ubizjak at gmail dot com
2021-06-11 10:32 ` cvs-commit at gcc dot gnu.org
2021-06-11 10:35 ` ubizjak at gmail dot com
2021-06-13 19:51 ` cvs-commit at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-101021-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).