]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
phiopt: use remove_phi_node instead of gsi_remove for phi node [PR125961]
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Tue, 30 Jun 2026 00:06:46 +0000 (17:06 -0700)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Tue, 30 Jun 2026 17:25:00 +0000 (10:25 -0700)
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 <andrew.pinski@oss.qualcomm.com>
gcc/tree-ssa-phiopt.cc

index 5c263df70ebfa1168353263cc842cad4e064237a..e12dc7a8b0cadf41991d642c4eaa2ac9f4b2de3c 100644 (file)
@@ -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);