new-regalloc.c patch

Denis Chertykov denisc@overta.ru
Fri Feb 2 23:19:00 GMT 2001


Daniel Berlin <dberlin@redhat.com> writes:

> > > > 	(edge_weight): Weight of edge between v1 and v2 equal to hard
> > > > 	regs count in v2.
> > >
> > > This is wrong.
> > > The edge weight is dependent on the number of hard regs in both. The
> > > reason i left out the other cases is because i couldn't figure them out in
> > > my head, and they didn't seem to crop up.
> > >
> > > edge_weight (v1,v2) is directly dependent on how much v2 can block
> > > coloring of v1, and v1 can block coloring of v2.
> >
> > v2 of v1 and v1 of v2 isn't the same.
> yes it is, because v2 + v1 == v1 + v2.

Is you agree with "edge_weight isn't commutative" ?
IE: Can be (not must be) edge_weight (v1, v2) != edge_weight (v2, v1)

> > So,
> > edge_weight (v1,v2) + edge_weight (v2,v1)
> > == (CLASS_MAX_NREGS (reg_preferred_class (v1), PSEUDO_REGNO_MODE (v1)
> >     + CLASS_MAX_NREGS (reg_preferred_class (v2), PSEUDO_REGNO_MODE (v2))
> 
> Not quite.
> If each has two registers, you have a weight of two, not four.

Why you think that weight is four ?
It's only a thesis not a weight calculation.

(edge_weight (v1,v2) + edge_weight (v2,v1)) must be equal to
(hard regs of v1) + (hard regs of v2)

Am I wrong ?

> > IE: For edge_weight (v1,v2): v2 can block
> > CLASS_MAX_NREGS (regclass-v2, mode-of-v2) colors of v1.
> >
> > (IMHO: I can be wrong here, but I don't know where.)

Where I'm wrong ?

> >From machsuif, who uses this method as well:
> static int
> edge_weight(var_node *n1, var_node *n2)
> {
>    int w1 = (n1->status == PRECOLORED ? 0 : regs_needed(n1));
>    int w2 = (n2->status == PRECOLORED ? 0 : regs_needed(n2));
> 
>    switch(w1 + w2) {
>      case 0:
>      case 1:
>      case 2: return 1;
>      case 3: return 2;
>      case 4: return (unaligned_pairs ? 3 : 2);
>      default: assert(FALSE);
>    }
>    return -1;                   /* pacify compiler */
> }

Procedure above is commutative.
IE: edge_weight (v1,v2) == edge_weight (v2,v1)
It's strange for me.

What is edge_weight ?
IMHO: `edge_weight (v1, v2)' is a color count needed for coloring v2
and (edge_weight (v1, v2) + edge_weight (v2, v1)) is a count of colors
needed for coloring both v1 and v2.

Example:
v1 require one hard register;
v2 require three hard registers.

edge_weight (v1, v2) is 3 it's true because v2 block 3 colors for v1.
edge_weight (v2, v1) is 3 - I can't understand why, because v1 block
only one color for v2.

My thought:

Graph consisted of v1 and v2 can be colored by four colors.
IE colors needed for v2 plus color needed for v1.
edge_weight (v2, v1) is 1, because colors needed for v2 is 3 and summ
is 4.
Or.
Color needed for v1 plus colors needed for coloring v2.
edge_weight (v1, v2) is 3, because v1 need 1 color and v2 needed in 3
colors. 

Please point me where I'm wrong. (if it is)

> >    On some machines, double-precision values must be kept in even/odd
> >    register pairs.  The way to implement that is to define this macro
> >    to reject odd register numbers for such modes.
> > --------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> Wheee.
> 
> Let me double check that the change doesn't break anything for weird
> reasons, and i'll check it in as well.

Is you agree here (remove HARD_REGNO_MODE_OK) ?



More information about the Gcc-patches mailing list