From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5CD103858D38; Sat, 13 May 2023 05:47:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5CD103858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683956848; bh=sjRyBcAej+KCZHIRRNNNLNCC7Ea+hDX6c/te+WZWNkQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=e6+xpdd1HyxDrCziy2F/Kzm7XdYlLU8DSEE9nXhPxR+nf5answetbiTzFhq7Dtxy4 9dDHwBfZNBOAhp7goRTXJlaxG1uPJCEfpXedThEpK4Ty9Z1KnCFwC+tfc/ki7UrCOV z910oKqdWkrDcphMCuxy2zj1wENJ9JCrYTjycPbA= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/95408] Failure to optimize bitwise and with negated conditional using the same operand to conditional with decremented operand Date: Sat, 13 May 2023 05:47:28 +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: 11.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: everconfirmed assigned_to cf_reconfirmed_on bug_status 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=3D95408 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot = gnu.org Last reconfirmed| |2023-05-13 Status|UNCONFIRMED |ASSIGNED --- Comment #1 from Andrew Pinski --- For unsigned x (to simplify things first). In forwardprop4 we have _1 =3D x_4(D) <=3D 121211; _3 =3D _1 ? x_4(D) : 0; _5 =3D _3 !=3D 0; This could be done as: x_4(D) <=3D 121211 ? x_4(D) !=3D 0 : 0 Which then would be: (x_4(D) <=3D 121211 & x_4(D) !=3D 0)=20 ((x_4(D) - 1) <=3D 121210) So I have a patch which does the second step into the 3rd expression (there= is another bug or 2 about it). the 3rd expression into the final is already do= ne. It is just the first that needs to happen to written up. Something like this for the first step. (for op (tcc_comparison) /* (c ? a : CST0) op CST1 --> c ? (a op CST1) : (CST0 op CST1) */ (simplify (op (cond:s @0 @1 CONSTANT_CLASS_P@2) CONSTANT_CLASS_P@3) (cond! @0 (op @1 @3) (op @2 @4))) So mine.=