From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E93313857C69; Mon, 5 Apr 2021 20:15:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E93313857C69 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/99918] New: suboptimal code for bool bitfield tests Date: Mon, 05 Apr 2021 20:15:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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: Mon, 05 Apr 2021 20:15:30 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99918 Bug ID: 99918 Summary: suboptimal code for bool bitfield tests Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- GCC does a better job folding operations involving plain Booleans than it d= oes with bool bit-fields. The example below shows that in f() the return state= ment is folded to zero while in g() it's not. This is behind a class of -Wmaybe-uninitialized warnings. $ cat z.c && gcc -O2 -S -Wall -fdump-tree-optimized=3D/dev/stdout z.c struct A { _Bool i, j; }; _Bool f (struct A a) { if (a.i) a.j =3D 0; else a.j =3D a.i; return a.j; // folded to 0 } struct B { _Bool i: 1, j: 1; }; _Bool g (struct B b) { if (b.i) b.j =3D 0; else b.j =3D b.i; return b.j; // not folded } ;; Function f (f, funcdef_no=3D0, decl_uid=3D1946, cgraph_uid=3D1, symbol_o= rder=3D0) _Bool f (struct A a) { [local count: 1073741824]: return 0; } ;; Function g (g, funcdef_no=3D1, decl_uid=3D1953, cgraph_uid=3D2, symbol_o= rder=3D1) Removing basic block 5 _Bool g (struct B b) { _Bool b$j; unsigned char _1; unsigned char _2; _Bool _3; [local count: 1073741824]: _1 =3D VIEW_CONVERT_EXPR(b); _2 =3D _1 & 1; if (_2 !=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 536870913]: _3 =3D b.i; [local count: 1073741824]: # b$j_5 =3D PHI <0(2), _3(3)> return b$j_5; }=