Commit 066aca28 by Richard Kenner

(count_possible_groups) Pass CLASS as arg and only try to find groups

of that class.

From-SVN: r7915
parent a49fdcae
...@@ -327,7 +327,7 @@ struct hard_reg_n_uses { int regno; int uses; }; ...@@ -327,7 +327,7 @@ struct hard_reg_n_uses { int regno; int uses; };
static int possible_group_p PROTO((int, int *)); static int possible_group_p PROTO((int, int *));
static void count_possible_groups PROTO((int *, enum machine_mode *, static void count_possible_groups PROTO((int *, enum machine_mode *,
int *)); int *, int));
static int modes_equiv_for_class_p PROTO((enum machine_mode, static int modes_equiv_for_class_p PROTO((enum machine_mode,
enum machine_mode, enum machine_mode,
enum reg_class)); enum reg_class));
...@@ -1603,7 +1603,8 @@ reload (first, global, dumpfile) ...@@ -1603,7 +1603,8 @@ reload (first, global, dumpfile)
/* If any single spilled regs happen to form groups, /* If any single spilled regs happen to form groups,
count them now. Maybe we don't really need count them now. Maybe we don't really need
to spill another group. */ to spill another group. */
count_possible_groups (group_size, group_mode, max_groups); count_possible_groups (group_size, group_mode, max_groups,
class);
if (max_groups[class] <= 0) if (max_groups[class] <= 0)
break; break;
...@@ -2063,68 +2064,65 @@ possible_group_p (regno, max_groups) ...@@ -2063,68 +2064,65 @@ possible_group_p (regno, max_groups)
return 0; return 0;
} }
/* Count any groups that can be formed from the registers recently spilled. /* Count any groups of CLASS that can be formed from the registers recently
This is done class by class, in order of ascending class number. */ spilled. */
static void static void
count_possible_groups (group_size, group_mode, max_groups) count_possible_groups (group_size, group_mode, max_groups, class)
int *group_size; int *group_size;
enum machine_mode *group_mode; enum machine_mode *group_mode;
int *max_groups; int *max_groups;
int class;
{ {
int i; HARD_REG_SET new;
int i, j;
/* Now find all consecutive groups of spilled registers /* Now find all consecutive groups of spilled registers
and mark each group off against the need for such groups. and mark each group off against the need for such groups.
But don't count them against ordinary need, yet. */ But don't count them against ordinary need, yet. */
for (i = 0; i < N_REG_CLASSES; i++) if (group_size[class] == 0)
if (group_size[i] > 1) return;
{
HARD_REG_SET new;
int j;
CLEAR_HARD_REG_SET (new); CLEAR_HARD_REG_SET (new);
/* Make a mask of all the regs that are spill regs in class I. */ /* Make a mask of all the regs that are spill regs in class I. */
for (j = 0; j < n_spills; j++) for (i = 0; i < n_spills; i++)
if (TEST_HARD_REG_BIT (reg_class_contents[i], spill_regs[j]) if (TEST_HARD_REG_BIT (reg_class_contents[class], spill_regs[i])
&& ! TEST_HARD_REG_BIT (counted_for_groups, spill_regs[j]) && ! TEST_HARD_REG_BIT (counted_for_groups, spill_regs[i])
&& ! TEST_HARD_REG_BIT (counted_for_nongroups, && ! TEST_HARD_REG_BIT (counted_for_nongroups, spill_regs[i]))
spill_regs[j])) SET_HARD_REG_BIT (new, spill_regs[i]);
SET_HARD_REG_BIT (new, spill_regs[j]);
/* Find each consecutive group of them. */ /* Find each consecutive group of them. */
for (j = 0; j < FIRST_PSEUDO_REGISTER && max_groups[i] > 0; j++) for (i = 0; i < FIRST_PSEUDO_REGISTER && max_groups[class] > 0; i++)
if (TEST_HARD_REG_BIT (new, j) if (TEST_HARD_REG_BIT (new, i)
&& j + group_size[i] <= FIRST_PSEUDO_REGISTER && i + group_size[class] <= FIRST_PSEUDO_REGISTER
/* Next line in case group-mode for this class && HARD_REGNO_MODE_OK (i, group_mode[class]))
demands an even-odd pair. */
&& HARD_REGNO_MODE_OK (j, group_mode[i]))
{ {
int k; for (j = 1; j < group_size[class]; j++)
for (k = 1; k < group_size[i]; k++) if (! TEST_HARD_REG_BIT (new, i + j))
if (! TEST_HARD_REG_BIT (new, j + k))
break; break;
if (k == group_size[i])
if (j == group_size[class])
{ {
/* We found a group. Mark it off against this class's /* We found a group. Mark it off against this class's need for
need for groups, and against each superclass too. */ groups, and against each superclass too. */
register enum reg_class *p; register enum reg_class *p;
max_groups[i]--;
p = reg_class_superclasses[i]; max_groups[class]--;
p = reg_class_superclasses[class];
while (*p != LIM_REG_CLASSES) while (*p != LIM_REG_CLASSES)
max_groups[(int) *p++]--; max_groups[(int) *p++]--;
/* Don't count these registers again. */ /* Don't count these registers again. */
for (k = 0; k < group_size[i]; k++) for (j = 0; j < group_size[j]; j++)
SET_HARD_REG_BIT (counted_for_groups, j + k); SET_HARD_REG_BIT (counted_for_groups, i + j);
}
/* Skip to the last reg in this group. When j is incremented
above, it will then point to the first reg of the next
possible group. */
j += k - 1;
}
} }
/* Skip to the last reg in this group. When i is incremented above,
it will then point to the first reg of the next possible group. */
i += j - 1;
}
} }
/* ALLOCATE_MODE is a register mode that needs to be reloaded. OTHER_MODE is /* ALLOCATE_MODE is a register mode that needs to be reloaded. OTHER_MODE is
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment