From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 394CE3858D37; Thu, 27 Apr 2023 22:31:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 394CE3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682634709; bh=Ut3ROzuTiRrWjqHNsWAzyA07nozsX2PqnpN1QNbHwe0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TyAPuYzSakrxXR7dV8j/r7HIdXDZUhE8RzjHGMxbhBxNPzYteu3SWx1diXDP68Pz6 ypPpOU6SkBIg23Bq+DD9RIokuZqnopMhTGa3wIJr1rH2LfLUJpRt/GFM19qWP++/z4 1LMEYNpz1ZE9r7+GLJ0kzVVvLG1/RxG7gZ782rUg= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/79119] absolute value of a pointer difference can be assumed to be less than or equal to PTRDIFF_MAX Date: Thu, 27 Apr 2023 22:31:48 +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: 7.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW 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: 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=3D79119 --- Comment #3 from Andrew Pinski --- So a couple of things need to happen really: optimized now: if (p_10 < q_12) goto ; [50.00%] else goto ; [50.00%] [local count: 536870913]: _3 =3D _22 - _21; _4 =3D _3 /[ex] 4; iftmp.0_14 =3D (long unsigned int) _4; goto ; [100.00%] [local count: 536870913]: _5 =3D _21 - _22; _6 =3D _5 /[ex] 4; iftmp.0_13 =3D (long unsigned int) _6; [local count: 1073741824]: # iftmp.0_7 =3D PHI I have a patch which is able to move the cast out of the PHI (will be posti= ng it today or tomorrow). The next thing is we need to move the /[ext] 4 out of the PHI, I have not extended PHIOPT to do that just yet (just extended it to handle unary operations though). And then we have to see the abs but with _22/_21 being unrelated to p_10/q_= 12 except with a cast, it might be hard. I am looking into a patch for the case where if _22/_21 was in the conditional.=