From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EB6853858034; Tue, 6 Apr 2021 08:39:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EB6853858034 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/99918] [9/10/11 Regression] suboptimal code for bool bitfield tests Date: Tue, 06 Apr 2021 08:39:22 +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: normal X-Bugzilla-Who: rguenth 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: 9.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on blocked everconfirmed target_milestone 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, 06 Apr 2021 08:39:23 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99918 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2021-04-06 Blocks| |85316 Ever confirmed|0 |1 Target Milestone|--- |9.4 --- Comment #5 from Richard Biener --- The main issue is optimize_bit_field_compare in fold-const.c which produces during GENERIC folding in .005t.original: if ((BIT_FIELD_REF & 1) !=3D 0) { b.j =3D 0; } else { b.j =3D b.i; } return b.j; that's premature in this place. For f() it also takes until DOM3 to do the folding unless you disable SRA which then makes EVRP recognize the second store as a.j =3D 0. With SRA we fail to derive ranges for a_10 in a_10 =3D MEM [(struct A *)&a]; a$1_11 =3D MEM [(struct A *)&a + 1B]; _1 =3D VIEW_CONVERT_EXPR<_Bool>(a_10); if (_1 !=3D 0) goto ; [INV] else goto ; [INV] : : # a$1_9 =3D PHI <0(2), a_10(3)> _7 =3D VIEW_CONVERT_EXPR<_Bool>(a$1_9); thus we're missing looking through VIEW_CONVERT_EXPR in register_assert_for. Amending that would eventually also allow optimizing the prematurely folded vairant. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D85316 [Bug 85316] [meta-bug] VRP range propagation missed cases=