From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2E0273851C18; Thu, 10 Jun 2021 18:07:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E0273851C18 From: "ubizjak at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ubizjak at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jun 2021 18:07:14 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101021 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,1= 4,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, 1= 4,15 }); --cut here-- compiles with -O2 -msse2 to: : pshufd $0xea,%xmm0,%xmm0 retq=20=20=20 : pshuflw $0xd4,%xmm0,%xmm0 retq=20=20=20 : pshufhw $0xd4,%xmm0,%xmm0 retq=20=20=20 Using -msse4 (or higher ISA), the compiler is too eager to emit less optimal PSHUFB: : pshufb 0x0(%rip),%xmm0 retq=20=20=20 : pshufb 0x0(%rip),%xmm0 retq=20=20=20 : pshufb 0x0(%rip),%xmm0 retq=