From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BAEA03858D39; Thu, 9 May 2024 12:59:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BAEA03858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715259549; bh=cuqd6ww8biL2L2dz8x6XCHyvu/Xx3p0syOIajpbwgaA=; h=From:To:Subject:Date:From; b=FnRltbYo+JqmsEJfFQ5BzDDgpV6MafychjlH194pKvrAPTgbIH5cENiQqlFGPPTBf msx/5wVMegSSwP13JbaEpCPCEgvULmQQkK7LzWY7jg7wEOMiVC/nbLd+HcpXubOuo+ Ha9DYp3vJVH42jfrFZ06ZhlXdwX+1ioBUz5PWVUo= From: "652023330028 at smail dot nju.edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/115011] New: [14/15 Regression] Missed optimization: (bool) (f ? 1: t) ==> 1 when bool t = (0 >= f) + x; Date: Thu, 09 May 2024 12:59:09 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 15.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: 652023330028 at smail dot nju.edu.cn X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D115011 Bug ID: 115011 Summary: [14/15 Regression] Missed optimization: (bool) (f ? 1: t) =3D=3D> 1 when bool t =3D (0 >=3D f) + x; 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 tit= le, but gcc -O3 seems to have missed it. Reduced code: https://godbolt.org/z/xE6GEEn7j bool x; bool fn3(unsigned long long int f) { bool t =3D (0 >=3D f) + x; return f ? 1: t; } GCC -O3: fn3(unsigned long long): movzx eax, BYTE PTR x[rip] cmp rdi, 1 adc eax, 0 test eax, eax setne al test rdi, rdi setne dl or eax, edx ret Expected code (GCC-13.2): fn3(unsigned long long): mov eax, 1 ret Thank you very much for your time and effort! We look forward to hearing fr= om you.=