> Am 16.11.2025 um 06:26 schrieb Andrew Pinski <[email protected]>:
>
> I had messed up the check in r16-5258-g1d8e2d51e5c5cb for preheaders
> where return to remvoe the forwarder preheader block even if
> LOOPS_HAVE_PREHEADERS
> was set. I am not sure how often this happens because most of the time the
> pre-header
> will have an incoming phi block anyways but it is safer not to remove it in
> this case.
>
> Bootstrapped and tested on x86_64-linux-gnu.
Ok
> gcc/ChangeLog:
>
> * tree-cfgcleanup.cc (tree_forwarder_block_p): Restore check on
> LOOPS_HAVE_PREHEADERS.
>
> Signed-off-by: Andrew Pinski <[email protected]>
> ---
> gcc/tree-cfgcleanup.cc | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/gcc/tree-cfgcleanup.cc b/gcc/tree-cfgcleanup.cc
> index 9397031b225..9aeb4f3fc99 100644
> --- a/gcc/tree-cfgcleanup.cc
> +++ b/gcc/tree-cfgcleanup.cc
> @@ -519,11 +519,14 @@ tree_forwarder_block_p (basic_block bb)
> }
> /* cleanup_tree_cfg_noloop just created the loop preheader, don't
> remove it if it has phis. */
> - else if (bb->loop_father == loop_outer (dest->loop_father))
> - return gimple_seq_empty_p (phi_nodes (bb));
> - /* Always preserve other edges into loop headers that are
> - not simple latches or preheaders. */
> - return false;
> + else if (bb->loop_father == loop_outer (dest->loop_father)
> + && gimple_seq_empty_p (phi_nodes (bb))
> + && !loops_state_satisfies_p (LOOPS_HAVE_PREHEADERS))
> + ;
> + else
> + /* Always preserve other edges into loop headers that are
> + not simple latches or preheaders. */
> + return false;
> }
> }
>
> --
> 2.43.0
>