I've actually done that. I defined the expansion like this:

/* If we can create pseudos, the first operand is a register but the
second is memory */
  if (
        (
         can_create_pseudo_p () &&
         register_operand (operands[0], DImode)
      && memory_operand (operands[1], DImode)))
      {
        /* If the memory is not a REG */
        if (GET_CODE(XEXP (operands[1], 0)) != REG)
        {
        /* Make a register and move it there first before performing the load*/
        rtx tmp = gen_reg_rtx(DImode);
        emit_move_insn (tmp, XEXP (operands[1], 0));
        emit_move_insn (operands[0], gen_rtx_MEM (DImode,tmp));
        DONE;
        }
      }

Then I have my base cost for address_cost that is used and actually
does tell GCC that loading from a global address is expensive (I put a
value like 10 for that) whereas a register with an offset would get 2.

For the moment, no change, the expansion code is actually not used in
this case because GCC only presents me with the load from a global
during or after reload. Therefore, it's already done and he doesn't
seem to want to change his ways. I haven't played with the rtx_cost
but that's my next step.

Any comments, ideas?
Jc

On Wed, Apr 22, 2009 at 4:08 PM, Ian Lance Taylor <i...@google.com> wrote:
> Jean Christophe Beyler <jean.christophe.bey...@gmail.com> writes:
>
>> I've been working on the Machine description of my target and was
>> wondering if you could help me out here.
>>
>> I've been trying to force GCC out of it's habit of generating this code :
>> (insn 28 8 10 2 glob.c:13 (set (reg:DI 9 r9)
>>         (mem/s:DI (symbol_ref:DI ("data") <var_decl 0xb7e39688 data>)
>> [4 data+0 S8 A64])) 71 {*movdi_internal1} (nil))
>>
>> -> Load r9, 0(data)
>>
>> Because, in my target it's costly to do so, I would prefer :
>>
>> Mov r10, data
>> Load r9, 0(r10)
>>
>> This way, GCC can optimize this by taking the first move out of the
>> loop for example. Otherwise, I have do a final pass but that's too
>> late for all the optimizations.
>>
>> My problem is that I've defined the define_expand "movdi" and it only
>> sees the right case after reload is in progress or completed.
>> Therefore, I can't create any new pseudos.
>>
>> Any ideas on how to do this, I've been looking at the other
>> architectures but haven't seen anything that resembles this,
>
> This looks somewhat difficcult.  I would suggest having the movMM
> expander generate the two instruction sequence when can_create_pseudo_p
> returns true.  Then set the costs so that a load from an address plus an
> offset is expensive.
>
> Ian
>

Reply via email to