public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/101021] New: PSHUFB is emitted instead of PSHUFD, PSHUFLW and PSHUFHW with -msse4
@ 2021-06-10 18:07 ubizjak at gmail dot com
  2021-06-11  7:35 ` [Bug target/101021] " ubizjak at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ubizjak at gmail dot com @ 2021-06-10 18:07 UTC (permalink / raw)
  To: gcc-bugs

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

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

end of thread, other threads:[~2021-06-13 19:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10 18:07 [Bug target/101021] New: PSHUFB is emitted instead of PSHUFD, PSHUFLW and PSHUFHW with -msse4 ubizjak at gmail dot com
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

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).