https://gcc.gnu.org/g:faafcc163b261d640aad43dacc645fbc43db757c
commit r17-2027-gfaafcc163b261d640aad43dacc645fbc43db757c Author: Andrew Pinski <[email protected]> Date: Mon Jun 29 17:06:46 2026 -0700 phiopt: use remove_phi_node instead of gsi_remove for phi node [PR125961] While working on some other code I noticed that we call gsi_remove for the phi node but then don't release the phi node so it takes until the next gc to free it. This changes the 2 places in phiopt to use remove_phi_node instead of gsi_remove so that the phi node can be reused instead. Note we need to pass false here since we use the result of the phi still. Bootstrapped and tested on x86_64-linux-gnu. PR tree-optimization/125961 gcc/ChangeLog: * tree-ssa-phiopt.cc (factor_out_conditional_operation): Use remove_phi_node instead of gsi_remove for the phi node. (factor_out_conditional_load): Likewise. Signed-off-by: Andrew Pinski <[email protected]> Diff: --- gcc/tree-ssa-phiopt.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 5c263df70ebf..e12dc7a8b0ca 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -632,7 +632,7 @@ factor_out_conditional_operation (edge e0, edge e1, basic_block merge, /* Remove the original PHI stmt. */ gsi = gsi_for_stmt (phi); - gsi_remove (&gsi, true); + remove_phi_node (&gsi, false); statistics_counter_event (cfun, "factored out operation", 1); @@ -3860,7 +3860,7 @@ factor_out_conditional_load (edge e0, edge e1, basic_block merge, gphi *phi, /* RES is now defined by the load; drop the original PHI. */ gsi = gsi_for_stmt (phi); - gsi_remove (&gsi, true); + remove_phi_node (&gsi, false); /* The two arm loads are now dead. */ gsi = gsi_for_stmt (load0);
