summaryrefslogtreecommitdiff
path: root/gcc/tree-phinodes.c
diff options
context:
space:
mode:
authorkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>2004-11-23 05:25:12 +0000
committerkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>2004-11-23 05:25:12 +0000
commita77b4cdeb8acb5903bac195a555c7d2ad14226b7 (patch)
treef05fee1d28436abb25a6d378abbc0212ca41c4f5 /gcc/tree-phinodes.c
parent8dcb2d40524fd0524b4429d5cb40b79ff9def226 (diff)
downloadgcc-a77b4cdeb8acb5903bac195a555c7d2ad14226b7.tar.gz
* tree-cfg.c (tree_execute_on_growing_pred): New.
(tree_cfg_hooks): Add tree_execute_on_growing_pred. * tree-flow.h: Add a prototype for reserve_phi_args_for_new_edge. * tree-phinodes.c (reserve_phi_args_for_new_edge): New. (add_phi_arg): Don't resize a PHI array. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@91075 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-phinodes.c')
-rw-r--r--gcc/tree-phinodes.c62
1 files changed, 30 insertions, 32 deletions
diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c
index a6be8383855..031a606d0c6 100644
--- a/gcc/tree-phinodes.c
+++ b/gcc/tree-phinodes.c
@@ -269,6 +269,33 @@ resize_phi_node (tree *phi, int len)
*phi = new_phi;
}
+/* Reserve PHI arguments for a new edge to basic block BB. */
+
+void
+reserve_phi_args_for_new_edge (basic_block bb)
+{
+ tree *loc;
+ int len = EDGE_COUNT (bb->preds);
+ int cap = ideal_phi_node_len (len + 4);
+
+ for (loc = &(bb_ann (bb)->phi_nodes);
+ *loc;
+ loc = &PHI_CHAIN (*loc))
+ {
+ if (len > PHI_ARG_CAPACITY (*loc))
+ {
+ tree old_phi = *loc;
+
+ resize_phi_node (loc, cap);
+
+ /* The result of the phi is defined by this phi node. */
+ SSA_NAME_DEF_STMT (PHI_RESULT (*loc)) = *loc;
+
+ release_phi_node (old_phi);
+ }
+ }
+}
+
/* Create a new PHI node for variable VAR at basic block BB. */
tree
@@ -302,38 +329,9 @@ add_phi_arg (tree *phi, tree def, edge e)
gcc_assert (bb == bb_for_stmt (*phi));
- if (i >= PHI_ARG_CAPACITY (*phi))
- {
- tree old_phi = *phi;
-
- /* Resize the phi. Unfortunately, this will relocate it. */
- resize_phi_node (phi, ideal_phi_node_len (i + 4));
-
- /* resize_phi_node will necessarily relocate the phi. */
- gcc_assert (*phi != old_phi);
-
- /* The result of the phi is defined by this phi node. */
- SSA_NAME_DEF_STMT (PHI_RESULT (*phi)) = *phi;
-
- release_phi_node (old_phi);
-
- /* Update the list head if replacing the first listed phi. */
- if (phi_nodes (bb) == old_phi)
- bb_ann (bb)->phi_nodes = *phi;
- else
- {
- /* Traverse the list looking for the phi node to chain to. */
- tree p;
-
- for (p = phi_nodes (bb);
- p && PHI_CHAIN (p) != old_phi;
- p = PHI_CHAIN (p))
- ;
-
- gcc_assert (p);
- PHI_CHAIN (p) = *phi;
- }
- }
+ /* We resize PHI nodes upon edge creation. We should always have
+ enough room at this point. */
+ gcc_assert (PHI_NUM_ARGS (*phi) < PHI_ARG_CAPACITY (*phi));
/* Copy propagation needs to know what object occur in abnormal
PHI nodes. This is a convenient place to record such information. */