public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "652023330028 at smail dot nju.edu.cn" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/115202] New: [14/15 Regression] Missed optimization: std::min(f ? (unsigned short)m : a, ~0) Date: Thu, 23 May 2024 07:44:49 +0000 [thread overview] Message-ID: <bug-115202-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115202 Bug ID: 115202 Summary: [14/15 Regression] Missed optimization: std::min(f ? (unsigned short)m : a, ~0) Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: 652023330028 at smail dot nju.edu.cn Target Milestone: --- Hello, we noticed that the code below can be optimized to be independent of 'm', but gcc -O3 seems to have missed it. https://godbolt.org/z/a6MoofoYK unsigned short m; #include <algorithm> unsigned short func(int a, int f) { return std::min(f ? m : a, ~0); } GCC-trunk -O3: func(int, int): movzx eax, WORD PTR m[rip] test esi, esi mov edx, -1 cmove eax, edi test eax, eax cmovns eax, edx ret Expected code (gcc-13.2): func(int, int): mov eax, edi test edi, edi jns .L4 test esi, esi jne .L4 ret .L4: mov eax, 65535 ret If we did it correctly, it's caused by https://github.com/gcc-mirror/gcc/commit/7b34cacc5735385e7e2855d7c0a6fad60ef4a99b Thank you very much for your time and effort! We look forward to hearing from you.
next reply other threads:[~2024-05-23 7:44 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-05-23 7:44 652023330028 at smail dot nju.edu.cn [this message] 2024-05-23 9:02 ` [Bug tree-optimization/115202] " rguenth at gcc dot gnu.org 2024-05-23 12:18 ` [Bug tree-optimization/115202] [11/12/13/14/15 " pinskia at gcc dot gnu.org 2024-07-19 13:25 ` [Bug tree-optimization/115202] [12/13/14/15 " rguenth 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-115202-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).