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/114277] New: Missed optimization: x*(x||b) => x Date: Fri, 08 Mar 2024 05:31:04 +0000 [thread overview] Message-ID: <bug-114277-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114277 Bug ID: 114277 Summary: Missed optimization: x*(x||b) => x Product: gcc Version: 14.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 as stated in the title (x*(x||b) => x), but gcc -O3 missed it. https://godbolt.org/z/W8xYrGdej int a,b; void func(int x){ a=x*(x||b); } GCC -O3: func(int): mov eax, edi or eax, DWORD PTR b[rip] mov eax, 0 cmove edi, eax mov DWORD PTR a[rip], edi ret Expected code: func(int): mov DWORD PTR a[rip], edi ret Surprisingly, GCC optimizes as expected for the following slightly more complex code: int c; void func2(int x){ a=x*(x||(b&&c)); } func2(int): mov DWORD PTR a[rip], edi ret Thank you very much for your time and effort! We look forward to hearing from you.
next reply other threads:[~2024-03-08 5:31 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-08 5:31 652023330028 at smail dot nju.edu.cn [this message] 2024-03-08 6:10 ` [Bug tree-optimization/114277] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org 2024-03-08 10:24 ` rguenth at gcc dot gnu.org 2024-03-09 3:56 ` law at gcc dot gnu.org 2024-03-11 17:11 ` rzinsly at ventanamicro dot com 2024-03-11 17:33 ` pinskia at gcc dot gnu.org 2024-03-11 23:36 ` pinskia at gcc dot gnu.org 2024-03-12 0:45 ` 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-114277-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).