https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102880

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
So interestingly as a band-aid fix I bootstrapped and tested

diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index a016ee47a02..c2a0555dd78 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -351,6 +351,7 @@ tree_forwarder_block_p (basic_block bb, bool phi_wanted)
       /* If PHI_WANTED is false, BB must not have any PHI nodes.
         Otherwise, BB must have PHI nodes.  */
       || gimple_seq_empty_p (phi_nodes (bb)) == phi_wanted
+      || single_pred_p (bb) == phi_wanted
       /* BB may not be a predecessor of the exit block.  */
       || single_succ (bb) == EXIT_BLOCK_PTR_FOR_FN (cfun)
       /* Nor should this be an infinite loop.  */

which makes the forwarder block removal of CFG cleanup only remove forwarders
with a single predecessor (formerly it handled multiple predecessors if they
did not have PHIs).

There's no testsuite fallout from this patch but the testcase is fixed.

IMHO we should handle degenerate PHIs with a single predecessor here
and yank the PHI node restriction if we go with this.

It will still not catch all CD-DCE opportunities since that's of course not
a reliable way to have common arguments factored.  We talked a bit about
recovering the control dependence info of a virtuall inserted forwarder
but if possible it isn't anything trivial so I'd tend to go with explicit
factoring before running CD-DCE.

Reply via email to