public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "javier.martinez.bugzilla at gmail dot com" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-110724-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110724 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 = (count+7) / 8; switch(count%8) { case 0: do { *to++ = *from++; case 7: *to++ = *from++; case 6: *to++ = *from++; case 5: *to++ = *from++; case 4: *to++ = *from++; case 3: *to++ = *from++; case 2: *to++ = *from++; [[likely]] case 1: *to++ = *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 there 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.
next reply other threads:[~2023-07-18 17:11 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-07-18 17:11 javier.martinez.bugzilla at gmail dot com [this message] 2023-07-18 17:38 ` [Bug middle-end/110724] " pinskia at gcc dot gnu.org 2023-07-18 17:48 ` pinskia at gcc dot gnu.org 2023-07-18 19:07 ` javier.martinez.bugzilla at gmail dot com 2023-07-18 20:00 ` [Bug target/110724] " pinskia at gcc dot gnu.org 2023-07-18 20:02 ` pinskia at gcc dot gnu.org 2023-07-19 6:46 ` rguenth at gcc dot gnu.org 2023-07-19 8:26 ` javier.martinez.bugzilla at gmail dot com
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-110724-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: linkBe 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).