From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 544863858C39; Sat, 4 Dec 2021 15:37:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 544863858C39 From: "avi at scylladb dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/103554] New: -mavx generates worse code on scalar code Date: Sat, 04 Dec 2021 15:37:30 +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: 11.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: avi at scylladb 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: Sat, 04 Dec 2021 15:37:30 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103554 Bug ID: 103554 Summary: -mavx generates worse code on scalar code Product: gcc Version: 11.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: avi at scylladb dot com Target Milestone: --- Test case: struct s1 { long a, b, c, d, e, f, g, h; }; s1 move(s1 in) { s1 ret; ret.a =3D in.d; ret.b =3D in.e; ret.c =3D in.a; ret.d =3D in.b; return ret; } -O3 generates: move(s1): movq 8(%rsp), %xmm0 movq 32(%rsp), %xmm1 movq %rdi, %rax movhps 16(%rsp), %xmm0 movhps 40(%rsp), %xmm1 movups %xmm1, (%rdi) movups %xmm0, 16(%rdi) ret -O3 -mavx generates: move(s1): pushq %rbp movq %rdi, %rax movq %rsp, %rbp vmovq 16(%rbp), %xmm2 vmovq 40(%rbp), %xmm3 vpinsrq $1, 24(%rbp), %xmm2, %xmm1 vpinsrq $1, 48(%rbp), %xmm3, %xmm0 vinsertf128 $0x1, %xmm1, %ymm0, %ymm0 vmovdqu %ymm0, (%rdi) vzeroupper popq %rbp ret Clang -O3 generates this simple code, with or without -mavx (-mavx does use= VEX instructions): move(s1): # @move(s1) movq %rdi, %rax movups 32(%rsp), %xmm0 movups %xmm0, (%rdi) movaps 8(%rsp), %xmm0 movups %xmm0, 16(%rdi) retq=