diff options
author | Kazu Hirata <kazu@cs.umass.edu> | 2004-10-29 21:41:30 +0000 |
---|---|---|
committer | Kazu Hirata <kazu@gcc.gnu.org> | 2004-10-29 21:41:30 +0000 |
commit | 8c3babedce256be5e3663281952d055995dc05be (patch) | |
tree | 5c42227d182cef3486c320d7cd5a2c85cca2f302 /gcc | |
parent | 976c217af8797c7e09562a833dd772200a45de3e (diff) | |
download | gcc-8c3babedce256be5e3663281952d055995dc05be.zip gcc-8c3babedce256be5e3663281952d055995dc05be.tar.gz gcc-8c3babedce256be5e3663281952d055995dc05be.tar.bz2 |
tree-phinodes.c (allocate_phi_node): New.
* tree-phinodes.c (allocate_phi_node): New.
(make_phi_node, resize_phi_node): Use it.
From-SVN: r89852
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/tree-phinodes.c | 102 |
2 files changed, 49 insertions, 58 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 29458ae3..f43290d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-10-29 Kazu Hirata <kazu@cs.umass.edu> + + * tree-phinodes.c (allocate_phi_node): New. + (make_phi_node, resize_phi_node): Use it. + 2004-10-29 David Edelsohn <edelsohn@gnu.org> * config/rs6000/sysv4.h (TARGET_POWER): Define as 0. diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c index f45479e..71f0498 100644 --- a/gcc/tree-phinodes.c +++ b/gcc/tree-phinodes.c @@ -123,6 +123,47 @@ phinodes_print_statistics (void) } #endif +/* Allocate a PHI node with at least LEN arguments. If the free list + happens to contain a PHI node with LEN arguments or more, return + that one. */ + +static inline tree +allocate_phi_node (int len) +{ + tree phi; + int bucket = NUM_BUCKETS - 2; + int size = (sizeof (struct tree_phi_node) + + (len - 1) * sizeof (struct phi_arg_d)); + + if (free_phinode_count) + for (bucket = len - 2; bucket < NUM_BUCKETS - 2; bucket++) + if (free_phinodes[bucket]) + break; + + /* If our free list has an element, then use it. */ + if (bucket < NUM_BUCKETS - 2 + && PHI_ARG_CAPACITY (free_phinodes[bucket]) >= len) + { + free_phinode_count--; + phi = free_phinodes[bucket]; + free_phinodes[bucket] = PHI_CHAIN (free_phinodes[bucket]); +#ifdef GATHER_STATISTICS + phi_nodes_reused++; +#endif + } + else + { + phi = ggc_alloc (size); +#ifdef GATHER_STATISTICS + phi_nodes_created++; + tree_node_counts[(int) phi_kind]++; + tree_node_sizes[(int) phi_kind] += size; +#endif + } + + return phi; +} + /* Given LEN, the original number of requested PHI arguments, return a new, "ideal" length for the PHI node. The "ideal" length rounds the total size of the PHI node up to the next power of two bytes. @@ -165,39 +206,10 @@ tree make_phi_node (tree var, int len) { tree phi; - int size; - int bucket = NUM_BUCKETS - 2; len = ideal_phi_node_len (len); - size = sizeof (struct tree_phi_node) + (len - 1) * sizeof (struct phi_arg_d); - - if (free_phinode_count) - for (bucket = len - 2; bucket < NUM_BUCKETS - 2; bucket++) - if (free_phinodes[bucket]) - break; - - /* If our free list has an element, then use it. */ - if (bucket < NUM_BUCKETS - 2 - && PHI_ARG_CAPACITY (free_phinodes[bucket]) >= len) - { - free_phinode_count--; - phi = free_phinodes[bucket]; - free_phinodes[bucket] = PHI_CHAIN (free_phinodes[bucket]); -#ifdef GATHER_STATISTICS - phi_nodes_reused++; -#endif - } - else - { - phi = ggc_alloc (size); -#ifdef GATHER_STATISTICS - phi_nodes_created++; - tree_node_counts[(int) phi_kind]++; - tree_node_sizes[(int) phi_kind] += size; -#endif - - } + phi = allocate_phi_node (len); /* We do not have to clear a part of the PHI node that stores PHI arguments, which is safe because we tell the garbage collector to @@ -237,42 +249,16 @@ release_phi_node (tree phi) static void resize_phi_node (tree *phi, int len) { - int size, old_size; + int old_size; tree new_phi; - int bucket = NUM_BUCKETS - 2; gcc_assert (len >= PHI_ARG_CAPACITY (*phi)); /* Note that OLD_SIZE is guaranteed to be smaller than SIZE. */ old_size = (sizeof (struct tree_phi_node) + (PHI_ARG_CAPACITY (*phi) - 1) * sizeof (struct phi_arg_d)); - size = sizeof (struct tree_phi_node) + (len - 1) * sizeof (struct phi_arg_d); - - if (free_phinode_count) - for (bucket = len - 2; bucket < NUM_BUCKETS - 2; bucket++) - if (free_phinodes[bucket]) - break; - /* If our free list has an element, then use it. */ - if (bucket < NUM_BUCKETS - 2 - && PHI_ARG_CAPACITY (free_phinodes[bucket]) >= len) - { - free_phinode_count--; - new_phi = free_phinodes[bucket]; - free_phinodes[bucket] = PHI_CHAIN (free_phinodes[bucket]); -#ifdef GATHER_STATISTICS - phi_nodes_reused++; -#endif - } - else - { - new_phi = ggc_alloc (size); -#ifdef GATHER_STATISTICS - phi_nodes_created++; - tree_node_counts[(int) phi_kind]++; - tree_node_sizes[(int) phi_kind] += size; -#endif - } + new_phi = allocate_phi_node (len); memcpy (new_phi, *phi, old_size); |