From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7632B3858C50; Wed, 6 Apr 2022 06:33:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7632B3858C50 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/105161] variable constant-folded in its uses appears as optimized out depending on where it is assigned Date: Wed, 06 Apr 2022 06:33:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement 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: everconfirmed cf_reconfirmed_on cc bug_severity bug_status 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, 06 Apr 2022 06:33:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105161 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2022-04-06 CC| |aoliva at gcc dot gnu.org, | |rguenth at gcc dot gnu.org Severity|normal |enhancement Status|UNCONFIRMED |NEW --- Comment #1 from Richard Biener --- This is the same issue as PR105158 but this time there is really no place to put the debug stmt since the predecessor has two successors and the success= or has two predecessors. Since we want to generate the same code for -g and -= g0 the only option would be to never remove a forwarder block in such case, but that would cause an artificial unconditional jump in the assembly (that would then be the place the variable becomes live). Alternatively we could do liveness analysis for the special case of the successor having a backedge predecessor and see whether the variable can get a different value from that edge or not (in this case it can not). Maybe var-tracking dataflow would in the end compute this but then we'd have to arrange for the debug stmts to live on CFG edges (to avoid the empty forwarder block). We could also retain the forwarder and make sure it ends up fall-thru, then _maybe_ that's enough to not cause worse code generation. Alex - any thoughts on the code-gen/var-tracking issue? I suppose we really don't want to go down adding debug stmts to edges, but retaining the forwar= der (at least with -Og?) would also avoid re-creating/re-removing it with each critical edge splitting.=