From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 528FD3858C50; Thu, 9 May 2024 00:16:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 528FD3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715213794; bh=bc8GDmq5UtObZgK6OQF915PNCP7fGnVRxwgvY95e3fY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=srsYPYj+jFLn4HmELgW1Lx7AaFNpaBdiyUJkMh45IxFOJwvDyFYRRZkX9LzsjNylW /d33B8Y38YBIeto8AJY7HFnISSN9WL/Sy2rhJqbqa2YxmJDV3o8A/kkct0KYI8gNju Quwu+vgyEQjGO/GIETgk3ySsP1C5wkcukDDkDUio= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114999] A few missing optimizations due to `a - b` and `b - a` not being detected as negatives of each other Date: Thu, 09 May 2024 00:16:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed 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: ASSIGNED 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: short_desc Message-ID: In-Reply-To: References: 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 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|`a - b =3D=3D b - a` -> `a =3D=3D |A few missing opti= mizations |b` |due to `a - b` and `b - a` | |not being detected as | |negatives of each other --- Comment #2 from Andrew Pinski --- Another one: ``` int f(int a, int b, int x) { x =3D a - b; int y =3D -x; return (x >=3D 0 ? x : 0) + (x <=3D 0 ? y : 0); } ``` This should be detected as `abs` (just like if the assignment to x is removed.=