From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A42DE3857828; Wed, 3 Mar 2021 14:37:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A42DE3857828 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/99101] optimization bug with -ffinite-loops Date: Wed, 03 Mar 2021 14:37:50 +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: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth 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: Wed, 03 Mar 2021 14:37:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99101 --- Comment #23 from Richard Biener --- Just for the record we had the idea to apply the "bolt" of marking the latch control dependence (as done for possibly infinite loops) for loops containi= ng stmts with side-effects. diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index c027230acdc..c07b60bf25c 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -695,6 +695,12 @@ propagate_necessity (bool aggressive) if (bb !=3D ENTRY_BLOCK_PTR_FOR_FN (cfun) && !bitmap_bit_p (visited_control_parents, bb->index)) mark_control_dependent_edges_necessary (bb, false); + /* If the stmt has side-effects the number of invocations matter. + In this case mark the containing loop control. */ + if (gimple_has_side_effects (stmt) + && bb->loop_father->num !=3D 0) + mark_control_dependent_edges_necessary (bb->loop_father->latch, + false); } if (gimple_code (stmt) =3D=3D GIMPLE_PHI But while that works for CDDCE1, CDDCE2 is presented a slightly altered CFG that somehow prevents it from working. Which also means that both loops need to be considered infinite for the present bolting to work.=