From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 284383853825; Tue, 1 Jun 2021 23:19:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 284383853825 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/96923] Failure to optimize a select-related bool pattern to or+not Date: Tue, 01 Jun 2021 23:19:05 +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: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Jun 2021 23:19:06 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96923 --- Comment #5 from Andrew Pinski --- (In reply to Andrew Pinski from comment #4) > Created attachment 50905 [details] > Patch which is in testing (needs testcases) >=20 > As I said for the case in this PR, it needs > https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571616.html too. >=20 > If you change !b to b; that is "!a ? b : 0", this patch will optimize it.= =20 > The other patch is needed to allow to move !b out of the conditional. This patch has one bug in it where we need a convert added. BUT then we run into a different missed optimization issue. _51 =3D p2_22 <=3D prephitmp_122; _44 =3D (logical(kind=3D4)) _51; _37 =3D p2_22 > prephitmp_122; _49 =3D (logical(kind=3D4)) _37; _38 =3D _49 & found_p_63; _46 =3D _38 | _44; This is really just: _51 =3D p2_22 <=3D prephitmp_122; _44 =3D (logical(kind=3D4)) _51; _46 =3D found_p_63| _44; That is we don't optimize: (a & ~b) | b into a | b if ~b has been converted already. The other thing I noticed is the cast should not be really needed but nothi= ng removes it; I will look at that later. Note I could rewrite the pattern to do the simplification of the constants manually but I want to try to avoid that.=