From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BA865385EC54; Thu, 20 May 2021 13:57:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA865385EC54 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug gcov-profile/100145] missed optimization for dead code elimination at -O3 (vs. -O2) Date: Thu, 20 May 2021 13:57:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: gcov-profile 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: --- 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: Thu, 20 May 2021 13:57:25 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100145 --- Comment #3 from Richard Biener --- Note after inlining we still have a backedge into BB 3: [local count: 1073741824]: c =3D 0; b.1_7 =3D b; if (b.1_7 !=3D 0) goto ; [34.00%] else goto ; [66.00%] [local count: 3318838410]: _9 =3D 1; _10 =3D 0; _11 =3D _9 & _10; if (_11 !=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 1659419208]: _12 =3D 0; _13 =3D _10 & _12; if (_13 !=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 829709603]: iftmp.0_14 =3D 1; [local count: 3318838410]: # iftmp.0_15 =3D PHI <0(3), 0(4), iftmp.0_14(5)> _19 =3D iftmp.0_15; _8 =3D _19; c =3D _8; if (_8 !=3D 0) goto ; [11.00%] else goto ; [89.00%] [local count: 1073741824]: but that's quickly elided by CCP after inlining producing [local count: 1073741824]: c =3D 0; b.1_7 =3D b; if (b.1_7 !=3D 0) goto ; [34.00%] else goto ; [66.00%] [local count: 3318838410]: if (0 !=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 1659419208]: if (0 !=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 829709603]: [local count: 3318838410]: c =3D 1; if (1 !=3D 0) goto ; [11.00%] else goto ; [89.00%] [local count: 1073741824]: and the CFG cleanup ends up with the following: [local count: 1073741824]: c =3D 0; b.1_7 =3D b; if (b.1_7 !=3D 0) goto ; [34.00%] else goto ; [66.00%] [local count: 3318838410]: c =3D 1; [local count: 1073741824]: d =3D 1; _1 =3D c; if (_1 > 100) goto ; [33.00%] else goto ; [67.00%] [local count: 354334800]: foo (); [local count: 1073741824]: return 0;=