From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 49B743858C50; Thu, 9 May 2024 00:11:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49B743858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715213478; bh=7nQMFLpZF1HWflf8Klftr+4MRPpmRtTmh2zqyjuB2MQ=; h=From:To:Subject:Date:From; b=UT5gk6gNF4HY1krAU405S8yFuB6Bk6VYxiUKQiBNW8xJPMHlfeUCpNaRIUWya4hfZ 8gJWP23G5R7xcgHPlbeIYe+YwZBctCvviKXkcFp13+KCRZlWJu4In91gwZxT9wAqVR y+NQCte7ZWti4OC0S3vZftoUndDQJ8HSlBCZxT5Q= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114999] New: `a - b == b - a` -> `a == b` Date: Thu, 09 May 2024 00:11:17 +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: pinskia 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=3D114999 Bug ID: 114999 Summary: `a - b =3D=3D b - a` -> `a =3D=3D b` Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: pinskia at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` int f(int a, int b, int c) { c =3D a - b; int d =3D -c; int t =3D c =3D=3D d; int t1 =3D c =3D=3D 0; return t =3D=3D t1; } ``` This is not able to optimize to 1 as we don't detect that `a - b` and `b - = a` are negative of each other. ``` (for cmp (eq ne) (simplify (cmp:c @0 (negate @0)) ``` needs to be improved.=