aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.c
diff options
context:
space:
mode:
authorKazu Hirata <kazu@cs.umass.edu>2004-11-19 22:14:35 +0000
committerKazu Hirata <kazu@gcc.gnu.org>2004-11-19 22:14:35 +0000
commit4f7db7f7d7857726bdafc0f6f17808bf6352f97f (patch)
tree568646c49f6870aa2d397a8a2e4daa11db9ab211 /gcc/tree-cfg.c
parent1d8a9009f57e41974a445e50660e3d9ed7c8f182 (diff)
downloadgcc-4f7db7f7d7857726bdafc0f6f17808bf6352f97f.zip
gcc-4f7db7f7d7857726bdafc0f6f17808bf6352f97f.tar.gz
gcc-4f7db7f7d7857726bdafc0f6f17808bf6352f97f.tar.bz2
tree-cfg.c (reinstall_phi_args): New.
* tree-cfg.c (reinstall_phi_args): New. (tree_split_edge): Use it after redirecting an edge. Don't modify PHI_ARG_EDGE. From-SVN: r90940
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r--gcc/tree-cfg.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index d771995..337463c 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -3113,6 +3113,31 @@ bsi_insert_on_edge_immediate (edge e, tree stmt)
Tree specific functions for CFG manipulation
---------------------------------------------------------------------------*/
+/* Reinstall those PHI arguments queued in OLD_EDGE to NEW_EDGE. */
+
+static void
+reinstall_phi_args (edge new_edge, edge old_edge)
+{
+ tree var, phi;
+
+ if (!PENDING_STMT (old_edge))
+ return;
+
+ for (var = PENDING_STMT (old_edge), phi = phi_nodes (new_edge->dest);
+ var && phi;
+ var = TREE_CHAIN (var), phi = PHI_CHAIN (phi))
+ {
+ tree result = TREE_PURPOSE (var);
+ tree arg = TREE_VALUE (var);
+
+ gcc_assert (result == PHI_RESULT (phi));
+
+ add_phi_arg (&phi, arg, new_edge);
+ }
+
+ PENDING_STMT (old_edge) = NULL;
+}
+
/* Split a (typically critical) edge EDGE_IN. Return the new block.
Abort on abnormal edges. */
@@ -3121,8 +3146,6 @@ tree_split_edge (edge edge_in)
{
basic_block new_bb, after_bb, dest, src;
edge new_edge, e;
- tree phi;
- int i, num_elem;
edge_iterator ei;
/* Abnormal edges cannot be split. */
@@ -3149,23 +3172,9 @@ tree_split_edge (edge edge_in)
new_edge->probability = REG_BR_PROB_BASE;
new_edge->count = edge_in->count;
- /* Find all the PHI arguments on the original edge, and change them to
- the new edge. Do it before redirection, so that the argument does not
- get removed. */
- for (phi = phi_nodes (dest); phi; phi = PHI_CHAIN (phi))
- {
- num_elem = PHI_NUM_ARGS (phi);
- for (i = 0; i < num_elem; i++)
- if (PHI_ARG_EDGE (phi, i) == edge_in)
- {
- PHI_ARG_EDGE (phi, i) = new_edge;
- break;
- }
- }
-
e = redirect_edge_and_branch (edge_in, new_bb);
gcc_assert (e);
- gcc_assert (!PENDING_STMT (edge_in));
+ reinstall_phi_args (new_edge, e);
return new_bb;
}