From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A6762385802D; Thu, 10 Mar 2022 10:06:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A6762385802D From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102879] [12 Regression] Dead Code Elimination Regression at -O3 Date: Thu, 10 Mar 2022 10:06:34 +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: 12.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: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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, 10 Mar 2022 10:06:34 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102879 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu.org --- Comment #4 from Richard Biener --- Specifically ;; basic block 3, loop depth 1 -;; pred: 12 +;; pred: 10 foo (); ;; succ: 4 ... +;; basic block 10, loop depth 1 +;; pred: 7 +;; 8 + # _51 =3D PHI <_55(7), _4(8)> + _59 =3D _30 >> _51; iftmp.4_60 =3D (char) _59; -;; succ: 12 - -;; basic block 12, loop depth 1 -;; pred: 10 -;; 11 - # iftmp.4_61 =3D PHI <_29(10), iftmp.4_60(11)> - _62 =3D (int) iftmp.4_61; + _62 =3D (int) iftmp.4_60; d =3D _62; if (_62 =3D=3D 0) - goto ; [33.00%] + goto ; [66.33%] else - goto ; [67.00%] + goto ; [33.67%] ;; succ: 3 ;; 4 the wrecking occurs in back_jt_path_registry::duplicate_thread_path via update_bb_profile_for_threading doing else if (!(prob =3D=3D profile_probability::always ())) { FOR_EACH_EDGE (c, ei, bb->succs) c->probability /=3D prob; but taken_edge is the skip edge. So it seems that this might be OK after all but we've threaded the "unlikely path", leaving the "likely" one exposed to the unroller most probable path with now the call to foo () more likely executed?! This is Checking profitability of path (backwards): bb:12 (4 insns) bb:10 Control statement insns: 2 Overall: 2 insns [5] Registering jump thread: (10, 12) incoming edge; (12, 4) nocopy; path: 10->12->4 SUCCESS where the 10->12 has 59% probability and the 10->4 67% Again not sure why we need to adjust the 12->3/4 probabilities on the path leading through 10->11? Sure, we need to adjust the incoming count into 12 and the counts of 3 and 4 but why adjust probabilities?=