From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 86D423858CDB; Tue, 21 Nov 2023 23:10:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 86D423858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700608204; bh=naO6IgA4Ev2ShO9JDr0HMhf38Rjk5F3sFcBIBRt63VA=; h=From:To:Subject:Date:From; b=On72GbAMcrAVuhx2O/RyopM5yUFHZRpMZPOjwBA9GDe8k+UI+wg5yecbF8Qk8kB/S oiyPdfiwnA4BXEz8F9KK7pmw6USZL9yiDjT0VCG9vl8iP3gW0WZSNS1OZmXrWz81Yh MKzEJwWIyvZWz7jwBjJxOBwoXKJXrhALbkxdNbDo= From: "goon.pri.low at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/112662] New: missed-optimization: loop increment until wrap Date: Tue, 21 Nov 2023 23:10:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: goon.pri.low at gmail dot com 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=3D112662 Bug ID: 112662 Summary: missed-optimization: loop increment until wrap Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: goon.pri.low at gmail dot com Target Milestone: --- This function: unsigned unopt(unsigned a) { while (++a > 999); return a; } unopt: lea eax, [rdi+1] xor edx, edx not edi cmp eax, 999 cmovbe edi, edx add eax, edi ret Can be optimized to: unsigned opt(unsigned a) { if (++a > 999) return a; return 0; } opt: lea eax, [rdi+1] xor edx, edx cmp eax, 999 cmovbe eax, edx ret (saving two valuable instructions)=