From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 466FA385773C; Tue, 18 Jul 2023 17:11:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 466FA385773C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689700311; bh=EoMoAhS3DHszIK+Ji589znt88AMSEBKb9EhoXsdAj5Y=; h=From:To:Subject:Date:From; b=r/81FwyboWoiPURhr4e2+Vn17L8oox0e/EDMY01f/jDQJrzhl3dZCDAi9vjlnYTDi RkVeGVWfFvjHuXEIOlrVXN/vh6EbLPgsO1aZFjXp9pSou69hwaspB6SD9yIF08/PZC SOOmJk0u7f0khrcKad69PNEcDfpBos5uA1gzCyEQ= From: "javier.martinez.bugzilla at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/110724] New: Unnecessary alignment on branch to unconditional branch targets Date: Tue, 18 Jul 2023 17:11:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: javier.martinez.bugzilla 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110724 Bug ID: 110724 Summary: Unnecessary alignment on branch to unconditional branch targets Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: javier.martinez.bugzilla at gmail dot com Target Milestone: --- https://godbolt.org/z/f7qMxxfMj void duff(int * __restrict to, const int * __restrict from, const int count) { int n =3D (count+7) / 8; switch(count%8) { case 0: do { *to++ =3D *from++; case 7: *to++ =3D *from++; case 6: *to++ =3D *from++; case 5: *to++ =3D *from++; case 4: *to++ =3D *from++; case 3: *to++ =3D *from++; case 2: *to++ =3D *from++; [[likely]] case 1: *to++ =3D *from++; } while (--n>0); } } Trunk with O3: jle .L1 [...] lea rax, [rax+4] jmp .L5 # <-- no fall-through to ret .p2align 4,,7 # <-- unnecessary alignment .p2align 3 .L1: ret I believe this 16-byte alignment is done to put the branch target at the beginning of a front-end instruction fetch block. That however seems unnecessary when the branch target is itself an unconditional branch, as the instructions to follow will not retire. In this example the degrade is code size / instruction caching only, as the= re is no possible fall-through to .L1 that would cause nop's to be consumed. Changing the C++ attribute to [[unlikely]] introduces fall-through, and GCC seems to remove the padding, which is great.=