On Sat, Jul 9, 2011 at 3:46 PM, Richard Henderson <r...@redhat.com> wrote:
> On 07/09/2011 02:41 PM, H.J. Lu wrote:
>> Hi,
>>
>> X32 uses movl instead of movabs for trampoline.  OK for trunk?
>>
>> Thanks.
>>
>> H.J.
>> ---
>> 2011-07-09  H.J. Lu  <hongjiu...@intel.com>
>>
>>       * config/i386/i386.c (ix86_trampoline_init): Use movl instead
>>       of movabs for x32.
>>
>> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
>> index 04cb07d..c852719 100644
>> --- a/gcc/config/i386/i386.c
>> +++ b/gcc/config/i386/i386.c
>> @@ -22721,13 +23030,14 @@ ix86_trampoline_init (rtx m_tramp, tree fndecl, 
>> rtx chain_value)
>>      }
>>    else
>>      {
>> -      int offset = 0;
>> +      int offset = 0, size;
>>
>>        /* Load the function address to r11.  Try to load address using
>>        the shorter movl instead of movabs.  We may want to support
>>        movq for kernel mode, but kernel does not use trampolines at
>>        the moment.  */
>> -      if (x86_64_zext_immediate_operand (fnaddr, VOIDmode))
>> +      if (TARGET_X32
>> +       || x86_64_zext_immediate_operand (fnaddr, VOIDmode))
>
> Is this change actually necessary?  I would think that the
> predicate has already been adjusted...
>
>> -      emit_move_insn (mem, gen_int_mode (0xba49, HImode));
>> +      /* Use the shorter movl instead of movabs for x32.  */
>> +      if (TARGET_X32)
>> +     {
>> +       size = 6;
>> +       emit_move_insn (mem, gen_int_mode (0xba41, HImode));
>
> Have I forgotten x86 encoding?  I thought movl imm,reg was 5 bytes...
>
>

You forgot the REX prefix:

[hjl@gnu-6 tmp]$ cat x.s
        mov $0x12340000, %r11d
[hjl@gnu-6 tmp]$ gcc -c x.s
[hjl@gnu-6 tmp]$ objdump -dw x.o

x.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <.text>:
   0:   41 bb 00 00 34 12       mov    $0x12340000,%r11d
[hjl@gnu-6 tmp]$




-- 
H.J.

Reply via email to