diff mbox

PATCH [7/n] X32: Handle address output and calls patterns

Message ID CAMe9rOqeBxn0YOhBi4BnrGri5xNQrEXVGovSRj745s=cmDd+uQ@mail.gmail.com
State New
Headers show

Commit Message

H.J. Lu July 20, 2011, 9 p.m. UTC
On Wed, Jul 20, 2011 at 1:09 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Jul 20, 2011 at 10:31 AM, Richard Henderson <rth@redhat.com> wrote:
>> On 07/20/2011 10:25 AM, H.J. Lu wrote:
>>> I am testing this patch.  OK for trunk if it works?
>>
>> Yep.
>>
>
> It doesn't work.  Looking into it.
>

We have

#define CASE_VECTOR_MODE \
 (!TARGET_LP64 || (flag_pic && ix86_cmodel != CM_LARGE_PIC) ? SImode : DImode)

There is no difference  between LP64 and X32 for PIC.  I am testing this
patch

---
---

Richard, is this OK for trunk with the last patch if they work?

Thanks.

Comments

Richard Henderson July 20, 2011, 9:24 p.m. UTC | #1
On 07/20/2011 02:00 PM, H.J. Lu wrote:
>        operands[0] = expand_simple_binop (Pmode, code, op0, op1, NULL_RTX, 0,
>  					 OPTAB_DIRECT);
>      }
> +  else if (TARGET_X32)
> +    operands[0] = convert_memory_address (Pmode, operands[0]);
>  })
> 
>  (define_insn "*tablejump_1"
> ---
> 
> Richard, is this OK for trunk with the last patch if they work?

Yeah.

I had put the convert_memory_address first, because I thought it
would help match modes inside the PIC section as well. Anyway, I
see that expand_simple_binop will handle mode conversions itself,
so this placement is also ok.  I'm only mildly curious as to why
that placement failed.


r~
H.J. Lu July 20, 2011, 9:40 p.m. UTC | #2
On Wed, Jul 20, 2011 at 2:24 PM, Richard Henderson <rth@redhat.com> wrote:
> On 07/20/2011 02:00 PM, H.J. Lu wrote:
>>        operands[0] = expand_simple_binop (Pmode, code, op0, op1, NULL_RTX, 0,
>>                                        OPTAB_DIRECT);
>>      }
>> +  else if (TARGET_X32)
>> +    operands[0] = convert_memory_address (Pmode, operands[0]);
>>  })
>>
>>  (define_insn "*tablejump_1"
>> ---
>>
>> Richard, is this OK for trunk with the last patch if they work?
>
> Yeah.
>
> I had put the convert_memory_address first, because I thought it
> would help match modes inside the PIC section as well. Anyway, I
> see that expand_simple_binop will handle mode conversions itself,
> so this placement is also ok.  I'm only mildly curious as to why
> that placement failed.
>

The difference is:

Working:

   72d0:       4e 63 3c b8             movslq (%rax,%r15,4),%r15
    72d4:       4c 01 f8                add    %r15,%rax
    72d7:       ff e0                   jmpq   *%rax

not working:

    72d0:       46 8b 3c b8             mov    (%rax,%r15,4),%r15d
    72d4:       4c 01 f8                add    %r15,%rax
    72d7:       ff e0                   jmpq   *%rax
diff mbox

Patch

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 6e1dbb8..09ea1d4 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -10996,9 +10996,6 @@ 
 	      (use (label_ref (match_operand 1 "" "")))])]
   ""
 {
-  if (TARGET_X32)
-    operands[0] = convert_memory_address (Pmode, operands[0]);
-
   /* In PIC mode, the table entries are stored GOT (32-bit) or PC (64-bit)
      relative.  Convert the relative address to an absolute address.  */
   if (flag_pic)
@@ -11030,6 +11027,8 @@ 
       operands[0] = expand_simple_binop (Pmode, code, op0, op1, NULL_RTX, 0,
 					 OPTAB_DIRECT);
     }
+  else if (TARGET_X32)
+    operands[0] = convert_memory_address (Pmode, operands[0]);
 })

 (define_insn "*tablejump_1"