This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: set_src_cost lying comment
- From: Richard Earnshaw <Richard dot Earnshaw at foss dot arm dot com>
- To: Jeff Law <law at redhat dot com>, gcc at gcc dot gnu dot org
- Date: Fri, 26 Jun 2015 09:56:43 +0100
- Subject: Re: set_src_cost lying comment
- Authentication-results: sourceware.org; auth=none
- References: <20150622055710 dot GQ1723 at bubble dot grove dot modra dot org> <558A3AA9 dot 6090406 at redhat dot com> <20150624091846 dot GC1723 at bubble dot grove dot modra dot org> <558ADF04 dot 9040807 at redhat dot com> <558BF3F7 dot 6080702 at foss dot arm dot com> <558C2C0F dot 6000808 at redhat dot com>
On 25/06/15 17:27, Jeff Law wrote:
> On 06/25/2015 06:28 AM, Richard Earnshaw wrote:
>> On 24/06/15 17:47, Jeff Law wrote:
>>> On 06/24/2015 03:18 AM, Alan Modra wrote:
>>>>
>>>> So in these examples we'd really like register moves to cost one
>>>> insn. Hmm, at least, moves from hard regs ought to cost something.
>>> The more I think about it, the more I think that's a reasonable step.
>>> Nothing should have cost 0.
>>>
>>> Jeff
>>
>> It really means what you mean by cost here. I think rtx_cost is really
>> talking about delta costs much of the time, so when recursing down
>>
>> plus (op1, op2)
>>
>> there's a cost from the plus, a cost from op1 and a cost from op2.
>>
>> I believe the idea behind reg being cost 0 is that when op1 and op2 are
>> both registers in the above expression the overall cost is just the cost
>> of the plus, with no additional cost coming from the operands.
> Perhaps, but it's also the case on the PPC and a variety of other
> architectures that there's no difference between a reg and some
> constants. And on some architectures the PLUS is no different than a
> logical operation or even a copy.
>
Indeed, but that's why you need TARGET_RTX_COSTS to spot where such
constants are used with no additional cost, or when more complex
sub-operations can be folded into the basic cost. Just assuming all
constants have zero cost would be equally wrong on most RISC processors,
since it would be unusual for such chips to support any arbitrary
constant in, say, a PLUS operation.
R.
>
>
>
>>
>> This leaves only one problem: if the entire expression is just
>>
>> reg
>>
>> then the overall cost becomes zero. We hit this problem because we only
>> look at the source cost, not the overall insn cost. Mostly that's ok,
>> but in the specific case of a move instruction it doesn't really
>> generate the desired result.
>>
>> Perhaps the best thing to do is to use the OUTER code to spot the
>> specific case where you've got a SET and return non-zero in that case.
> Seems like it's worth an experiment.
>
> jeff