This is the mail archive of the
mailing list for the GCC project.
Re: discouraging register use
DJ Delorie wrote:
To allow realod inheritance to work where the same value happens to lie around in a 'c'
class register, you also have to extend all the 'm' alternatives with a 'c':
[(set (match_operand:SI 0 "" "c,c,??mc,??mc")
How does this related to Richard's comment that this denigrates the "c" class also?
The cost applies to the alternatives. The alternatives with lower or no
expensive register use still have
a lower cost. The case Richard commented on was where combinations of c
with m could
only be accepted by the alternative that also accepted m/m and which was
the most costly.
(plus:SI (match_operand:SI 1 "" "0,0,0,0")
(match_operand:SI 1 "" "c,?mc,c,?mc")))]
and make sure the union of the two classes is a register class.
What about when there are three classes, say c, d, and m - do I need
cm, dm, and cdm unions, or just cm and dm?
The basic rule is that you want all the unions and intersections, so
that the set of register
classes forms a momoid both with union and intersection. Unions are
needed to build
up register classes from multiple constraint letters (or strings). In
order for the constraint
cdm to be meaningful, you need the unions cd and cdm. Intersections are
regclass considers registers that are used in instructions with
However, with complex register class arrangements, you might find that
it is better to leave out
some intersections to avoid REGNO_REG_CLASS becoming too small for some
and then you also might want to leave out some unions so that you get
When you go down that road, the order of the register classes also
becomes very important.
I suppose you really have to observe the register allocator doing the
wrong thing with a
more straightforward register class set in order to fully understand
these finer points.
Another thing to consider is if you want register class preferencing to ignore or further
penalize the 'm' class.
E.g. this would triple the penalty for register preferencing:
[(set (match_operand:SI 0 "" "c,c,??mc#????,??mc#????")
Ok, someone needs to write a book about all this ;-)
The other Richard did, long ago. The constraints (including the
modifiers) are described in md.texi.