[PATCH] Avoid re-allocating PHIs in split_edge

Richard Biener rguenther@suse.de
Tue Aug 22 09:22:00 GMT 2017


The following patch makes sure to not grow the number of incoming
edges in the destination when doing split_edge on GIMPLE.  That's
easy by first redirecting the existing edge to the destination
to the new block rather than creating the new fallthru from the
new block to the destination.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2017-08-22  Richard Biener  <rguenther@suse.de>

	* tree-cfg.c (gimple_split_edge): Avoid reallocating target
	PHI nodes.

Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c	(revision 251215)
+++ gcc/tree-cfg.c	(working copy)
@@ -2844,10 +2844,11 @@ gimple_split_edge (edge edge_in)
   new_bb = create_empty_bb (after_bb);
   new_bb->frequency = EDGE_FREQUENCY (edge_in);
   new_bb->count = edge_in->count;
-  new_edge = make_single_succ_edge (new_bb, dest, EDGE_FALLTHRU);
 
   e = redirect_edge_and_branch (edge_in, new_bb);
   gcc_assert (e == edge_in);
+
+  new_edge = make_single_succ_edge (new_bb, dest, EDGE_FALLTHRU);
   reinstall_phi_args (new_edge, e);
 
   return new_bb;



More information about the Gcc-patches mailing list