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]>
---
 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 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);
-- 
2.43.0

Reply via email to