public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "avi@cloudius-systems.com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/92985] missed optimization opportunity for switch linear transformation Date: Sat, 27 Mar 2021 10:33:32 +0000 [thread overview] Message-ID: <bug-92985-4-859DsfDn7q@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-92985-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92985 Avi Kivity <avi@cloudius-systems.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |avi@cloudius-systems.com --- Comment #5 from Avi Kivity <avi@cloudius-systems.com> --- Here's another example: #include <compare> int strong_ordering_to_int(std::strong_ordering x) { if (x == std::strong_ordering::equal) { return 0; } else if (x == std::strong_ordering::less) { return -1; } else if (x == std::strong_ordering::greater) { return 1; } __builtin_unreachable(); } Used to translate the new std::strong_ordering back to int (in this case for compatibility with older code, but one can imagine many such translations from opaque enums to another enum when crossing an API boundary). gcc generates (-O3) strong_ordering_to_int(std::strong_ordering): xorl %eax, %eax testb %dil, %dil je .L1 xorl %eax, %eax cmpb $-1, %dil setne %al leal -1(%rax,%rax), %eax .L1: ret Where it could have generated movsx %dil, %eax ret
next parent reply other threads:[~2021-03-27 10:33 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-92985-4@http.gcc.gnu.org/bugzilla/> 2021-03-27 10:33 ` avi@cloudius-systems.com [this message] 2021-04-27 11:38 ` jakub at gcc dot gnu.org 2021-07-28 7:04 ` rguenth at gcc dot gnu.org 2021-11-29 20:41 ` [Bug tree-optimization/92985] " 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-92985-4-859DsfDn7q@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).