From: Andrew Pinski Date: Tue, 30 Jun 2026 00:06:46 +0000 (-0700) Subject: phiopt: use remove_phi_node instead of gsi_remove for phi node [PR125961] X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=faafcc163b261d640aad43dacc645fbc43db757c;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 5c263df70eb..e12dc7a8b0c 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);