On Mon, Jun 22, 2026 at 1:03 AM Andrew Pinski
<[email protected]> wrote:
>
> This code dates before tuples so it used to do some tricks to try to insert
> at the begining of the basic block. Now post tuples, to insert at the begining
> of the basic block, you just need to use gsi_after_labels followed by
> gsi_insert_before. This changes to do just that and simplifies the code
> slightly.
>
> Bootstrapped and tested on x86_64-linux-gnu.

OK

> gcc/ChangeLog:
>
>         * tree-ssa-phiopt.cc (cond_store_replacement): Just call
>         gsi_insert_before instead of checking gsi_end_p.
>         (cond_if_else_store_replacement_1): Likewise.
>
> Signed-off-by: Andrew Pinski <[email protected]>
> ---
>  gcc/tree-ssa-phiopt.cc | 16 ++--------------
>  1 file changed, 2 insertions(+), 14 deletions(-)
>
> diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
> index 62e4765c392..ebdff20b69b 100644
> --- a/gcc/tree-ssa-phiopt.cc
> +++ b/gcc/tree-ssa-phiopt.cc
> @@ -3191,13 +3191,7 @@ cond_store_replacement (basic_block middle_bb, 
> basic_block join_bb, edge e0,
>
>    /* 4) Insert that PHI node.  */
>    gsi = gsi_after_labels (join_bb);
> -  if (gsi_end_p (gsi))
> -    {
> -      gsi = gsi_last_bb (join_bb);
> -      gsi_insert_after (&gsi, new_stmt, GSI_NEW_STMT);
> -    }
> -  else
> -    gsi_insert_before (&gsi, new_stmt, GSI_NEW_STMT);
> +  gsi_insert_before (&gsi, new_stmt, GSI_NEW_STMT);
>
>    if (dump_file && (dump_flags & TDF_DETAILS))
>      {
> @@ -3337,13 +3331,7 @@ cond_if_else_store_replacement_1 (basic_block then_bb, 
> basic_block else_bb,
>
>    /* 3) Insert that new store.  */
>    gsi = gsi_after_labels (join_bb);
> -  if (gsi_end_p (gsi))
> -    {
> -      gsi = gsi_last_bb (join_bb);
> -      gsi_insert_after (&gsi, new_stmt, GSI_NEW_STMT);
> -    }
> -  else
> -    gsi_insert_before (&gsi, new_stmt, GSI_NEW_STMT);
> +  gsi_insert_before (&gsi, new_stmt, GSI_NEW_STMT);
>
>    statistics_counter_event (cfun, "if-then-else store replacement", 1);
>
> --
> 2.43.0
>

Reply via email to