public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redbeard0531 at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/59429] Missed optimization opportunity in qsort-style comparison functions Date: Fri, 22 Mar 2024 10:55:47 +0000 [thread overview] Message-ID: <bug-59429-4-2TGys5MbkD@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-59429-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59429 --- Comment #16 from Mathias Stearn <redbeard0531 at gmail dot com> --- Trunk still generates different code for all cases (in some cases subtly so) for both aarch64 and x86_64: https://www.godbolt.org/z/1s6sxrMWq. For both arches, it seems like LE and LG generate the best code. On aarch64, they probably all have the same throughput, but EL and EG have a size penalty with an extra instruction. On x86_64, there is much more variety. EL and EG both get end up with a branch rather than being branchless, which is probably bad since comparison functions are often called in ways that the result branches are unpredictable. GE and GL appear to have regressed since this ticket was created. They now do the comparison twice rather than reusing the flags from the first comparison: comGL(int, int): xor eax, eax cmp edi, esi mov edx, 1 setl al neg eax cmp edi, esi cmovg eax, edx ret comGE(int, int): xor eax, eax cmp edi, esi mov edx, 1 setne al neg eax cmp edi, esi cmovg eax, edx ret
prev parent reply other threads:[~2024-03-22 10:55 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-12-09 11:35 [Bug rtl-optimization/59429] New: " jengelh at inai dot de 2013-12-09 13:16 ` [Bug rtl-optimization/59429] " hjl.tools at gmail dot com 2013-12-09 14:02 ` jengelh at inai dot de 2013-12-09 14:05 ` jengelh at inai dot de 2014-04-04 11:37 ` ktietz at gcc dot gnu.org 2014-05-02 15:58 ` law at redhat dot com 2014-05-02 15:59 ` law at redhat dot com 2014-05-02 16:03 ` ktietz at gcc dot gnu.org 2014-05-02 16:09 ` law at redhat dot com 2014-05-02 16:14 ` ktietz at gcc dot gnu.org 2014-05-02 16:33 ` law at redhat dot com 2014-05-02 16:42 ` ktietz at gcc dot gnu.org 2014-05-05 8:48 ` rguenth at gcc dot gnu.org 2014-05-30 8:33 ` ktietz at gcc dot gnu.org 2021-07-25 0:22 ` [Bug tree-optimization/59429] " pinskia at gcc dot gnu.org 2024-01-24 16:56 ` pinskia at gcc dot gnu.org 2024-03-22 10:55 ` redbeard0531 at gmail dot com [this message]
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-59429-4-2TGys5MbkD@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).