public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "miguel.ojeda.sandonis at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/97856] New: Missed optimization: repeated call Date: Mon, 16 Nov 2020 17:40:55 +0000 [thread overview] Message-ID: <bug-97856-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97856 Bug ID: 97856 Summary: Missed optimization: repeated call Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: miguel.ojeda.sandonis at gmail dot com Target Milestone: --- For code such as: void f(int); void g(int v) { switch (v) { case 1: f(1); case 2: f(2); case 3: f(3); default: f(4); } } GCC generates for e.g. x86_64: g(int): subq $8, %rsp cmpl $2, %edi je .L2 cmpl $3, %edi je .L3 cmpl $1, %edi je .L13 movl $4, %edi addq $8, %rsp jmp f(int) .L13: call f(int) .L2: movl $2, %edi call f(int) .L3: movl $3, %edi call f(int) movl $4, %edi addq $8, %rsp jmp f(int) Repeating the `f(4);` call can be avoided by reordering the cases, reducing code size.
next reply other threads:[~2020-11-16 17:40 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-16 17:40 miguel.ojeda.sandonis at gmail dot com [this message] 2020-11-17 7:12 ` [Bug rtl-optimization/97856] " rguenth at gcc dot gnu.org 2021-09-01 4:41 ` pinskia at gcc dot gnu.org 2021-09-01 4:41 ` pinskia at gcc dot gnu.org
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-97856-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).