From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EB07C3858C50; Thu, 9 May 2024 00:18:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EB07C3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715213893; bh=MD0C+dg5Lw5F5zXdj52dB/d190E8khx0Hip50YN6d1g=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PMil2PtS9Pm0Rt4SBHmYTEIH4kZu0nc/9Tqb/tLMeWqybheuFElbIeMBeeo+zaDwo 8NUCNWRJ2mhCdXrgcJv/7hbObf6TPxnvZg7/lghhDoWhfgw2ItU+3E5IBcdxPVKoy/ MwOzvW4VZcYrmNbIx1SOW+4DRJz/f7hxjTp3v8qg= 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:17:44 +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: 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 --- Comment #3 from Andrew Pinski --- (In reply to Andrew Pinski from comment #2) > 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); > } > ``` >=20 > This should be detected as `abs` (just like if the assignment to x= is > removed. ``` int f(int a, int b, int x) { x =3D a - b; int y =3D -x; return (x >=3D 0 ? x : 0) + (y >=3D 0 ? y : 0); } ```=