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/114969] New: [11/12/13/14/15 Regression] Missed optimization: (bool)((std::max((unsigned long long) 0, (unsigned long long) var_0)) | ( var_0 ? 1 : 0)) => (bool) var_0 Date: Tue, 07 May 2024 10:22:45 +0000 [thread overview] Message-ID: <bug-114969-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114969 Bug ID: 114969 Summary: [11/12/13/14/15 Regression] Missed optimization: (bool)((std::max((unsigned long long) 0, (unsigned long long) var_0)) | ( var_0 ? 1 : 0)) => (bool) var_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 as stated in the title ((bool)((std::max((unsigned long long) 0, (unsigned long long) var_0)) | ( var_0 ? 1 : 0)) => (bool) var_0), but gcc -O3 seems to have missed it. This is a regression from GCC-4.8.1. https://godbolt.org/z/zo86Gz74r #include <algorithm> bool result; void func(unsigned long long var_0) { result = (std::max((unsigned long long) 0, (unsigned long long) var_0)) | ( var_0 ? 1 : 0); } GCC -O3: <bb 2> [local count: 1073741824]: # DEBUG BEGIN_STMT _7 = var_0_5(D) != 0; _8 = (long long unsigned int) _7; _1 = var_0_5(D) | _8; _2 = _1 != 0; result = _2; return; func(unsigned long long): xor eax, eax test rdi, rdi setne al or rax, rdi setne BYTE PTR result[rip] ret Expected code (GCC-4.7.4): <bb 2>: # DEBUG __a => &D.9143 # DEBUG __b => &D.9144 D.9181_24 = var_0_2(D) != 0; result = D.9181_24; return; func(unsigned long long): test rdi, rdi setne BYTE PTR result[rip] ret Thank you very much for your time and effort! We look forward to hearing from you.
next reply other threads:[~2024-05-07 10:22 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-05-07 10:22 652023330028 at smail dot nju.edu.cn [this message] 2024-05-07 11:26 ` [Bug tree-optimization/114969] " rguenth at gcc dot gnu.org 2024-05-08 3:44 ` 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-114969-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).