This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Question on RTX_COST


> I have a question as to how the RTX_COST macro should be defined for a
> particular processor. The docs. indicate that the macro expresses the
> "relative" costs of a operation. My questions are:
> 
> 1.) What are the costs relative to (i.e how should I think about costs
> and their impact on cse)?

A fast instruction is supposed to have a cost of two.

> 2.) Do the costs reflect the number of cycles or the size of an
> instruction?

They are supposed to reflect the execution time in general; if optimizing for
size, however, they should rather reflect the size.

> Additionally I do not understand the macro COSTS_N_INSNS (which is
> defined as N * 4 -2). What does it reflect? Looking at its definition
> gives no clue. Normally I look at other machine ports to see how they
> define things but there is no common thread. Some ports use
> COSTS_N_INSNS, and some just return numbers. What is the right thing to
> do here?

In theory you should use COSTS_N_INSNS, and it reflects the assumption that
N instructions will always be scheduled badly.
In practice, you often get better results if you ignore COSTS_N_INSNS,
or use it only with an argument of one and multiply the result with the
number of equivalent instructions, and work out the impact of how well
the code is likely to be scheduled yourself.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]