@@ -63,11 +63,12 @@ along with GCC; see the file COPYING3. If not see
walking the elements of the last array entry would result in finding less
than .1% additional reusable PHI nodes.
- Note that we can never have less than two PHI argument slots. Thus,
- the -2 on all the calculations below. */
+ Note that we can never have less than MIN_PHI_ARGS argument slots. Thus,
+ the subtraction of MIN_PHI_ARGS on all the calculations below. */
#define NUM_BUCKETS 10
-static GTY ((deletable (""))) vec<gimple *, va_gc> *free_phinodes[NUM_BUCKETS - 2];
+#define MIN_PHI_ARGS 4
+static GTY ((deletable (""))) vec<gimple *, va_gc> *free_phinodes[NUM_BUCKETS - MIN_PHI_ARGS];
static unsigned long free_phinode_count;
static int ideal_phi_node_len (int);
@@ -94,17 +95,18 @@ static inline gphi *
allocate_phi_node (size_t len)
{
gphi *phi;
- size_t bucket = NUM_BUCKETS - 2;
+ size_t bucket = NUM_BUCKETS - MIN_PHI_ARGS;
size_t size = sizeof (struct gphi)
+ (len - 1) * sizeof (struct phi_arg_d);
if (free_phinode_count)
- for (bucket = len - 2; bucket < NUM_BUCKETS - 2; bucket++)
+ for (bucket = len - MIN_PHI_ARGS; bucket < NUM_BUCKETS - MIN_PHI_ARGS;
+ bucket++)
if (free_phinodes[bucket])
break;
/* If our free list has an element, then use it. */
- if (bucket < NUM_BUCKETS - 2
+ if (bucket < NUM_BUCKETS - MIN_PHI_ARGS
&& gimple_phi_capacity ((*free_phinodes[bucket])[0]) >= len)
{
free_phinode_count--;
@@ -145,9 +147,8 @@ ideal_phi_node_len (int len)
size_t size, new_size;
int log2, new_len;
- /* We do not support allocations of less than two PHI argument slots. */
- if (len < 2)
- len = 2;
+ /* We do not support allocations of less than MIN_PHI_ARGS argument slots. */
+ len = MAX (len, MIN_PHI_ARGS);
/* Compute the number of bytes of the original request. */
size = sizeof (struct gphi)
@@ -225,14 +226,13 @@ release_phi_node (gimple *phi)
/* Immediately return the memory to the allocator when we would
only ever re-use it for a smaller size allocation. */
- if (len - 2 >= NUM_BUCKETS - 2)
+ if (len >= NUM_BUCKETS)
{
ggc_free (phi);
return;
}
- bucket = len > NUM_BUCKETS - 1 ? NUM_BUCKETS - 1 : len;
- bucket -= 2;
+ bucket = len - MIN_PHI_ARGS;
vec_safe_push (free_phinodes[bucket], phi);
free_phinode_count++;
}