From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 037FB3858430; Fri, 31 May 2024 13:49:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 037FB3858430 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1717163377; bh=InfawXGVemA9tqbL42lJxy3DMyi7CKpw8kHqlHYl0Sw=; h=From:To:Subject:Date:From; b=wcnOOu6SUVWj0zonVHrKkWnuEwjxWgSkENBfpykOoCQIOqwiYbKx6UMTnTXtPi5NK 0Gr3n5ksrEQcFncwFUleujYTV2PWR+HnfqcOSKAnfFppFZuwjGCXtcP7m++P2/d0M+ P/h+0D1i+9aY1Eks6Y9rPmxuicO04LDGFfA6VCrs= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/115306] New: (X + 1) > Y ? -X : 1 pattern does not handle X=~X nor X = -X; Date: Fri, 31 May 2024 13:49:36 +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: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org 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 keywords 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=3D115306 Bug ID: 115306 Summary: (X + 1) > Y ? -X : 1 pattern does not handle X=3D~X nor X =3D -X; Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- The new pattern: /* (1 - X) > Y ? X : 1 simplifies to (-X) >=3D Y ? X : 1 when X is unsigned for the same logic as above, just replace X with -X. */ (simplify (cond (gt (minus integer_onep @0) @1) @0 integer_onep@2) (if (TYPE_UNSIGNED (type)) (cond (ge (negate @0) @1) @0 @2)))=