pocma...@gmail.com (Paulo J. Matos) writes: > I would like some clarification on the meaning of RTX Costs. > When optimising for speed I assume they estimate the time at which the > final generated code is going to take to execute for each rtx. > When optimising for size it is the estimated number of words that each > rtx will generate in the final image. Is this correct?
The costs are inherently backend dependent, so the specific meaning is up to the backend. However, what you describe is generally what most backends try to implement. > Moreover, is there a reason for the existence of COST_N_INSNS(x) and why > this multiplies x by 4? Is 4 just a special number? Any reason on why I > should be using COST_N_INSNS instead of just assigning *total (of > target_rtx_costs) to a simple integer? COSTS_N_INSNS is relevant because a bunch of machine independent code uses it to compare the cost of some expression to the cost of a register-to-register move. All such uses are somewhat dubious and should probably be eliminated in favor of delegating all cost questions to the backend. However, since they exist at present, you don't have to use COSTS_N_INSNS, but you do have to be aware of it. There is nothing special about the number 4, it's just chosen to give backends a bit of leeway in setting the costs of operations which are not quite as expensive as a full instruction, so that, e.g., they can assign different costs to different addressing modes. Ian