https://gcc.gnu.org/g:6523cf83a553a3ac9a0546370ddc98926575e440
commit r17-1752-g6523cf83a553a3ac9a0546370ddc98926575e440 Author: Andrew Pinski <[email protected]> Date: Sun Jun 21 11:22:09 2026 -0700 cselim: Just use gsi_insert_before instead of checking if it is the end [PR125917] 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. PR tree-optimization/125917 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]> Diff: --- 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 62e4765c392c..ebdff20b69bb 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);
