On Tue, Jul 26, 2011 at 4:59 PM, H.J. Lu <hongjiu...@intel.com> wrote:

> This patch fixes PIC with external symbol and updates
> x86_64_immediate_operand/x86_64_zext_immediate_operand/x86_64_movabs_operand
> for x32.

> 2011-07-26  H.J. Lu  <hongjiu...@intel.com>
>
>        PR target/49853
>        * config/i386/i386.c (ix86_expand_move): Call convert_to_mode
>        on legitimize_tls_address return if needed.  Allow ptr_mode for
>        symbolic operand with PIC.

Eh... half of your patch is just an unnecessary rename of a temporary
variable. See attached patch for a cleaned-up version.
Also, please use explicit DImode and SImode checks to match what
ix86_legitimate_address_p does.

>        * config/i386/predicates.md (x86_64_immediate_operand): Always
>        allow the offsetted memory references for TARGET_X32.
>        (x86_64_zext_immediate_operand): Likewise.
>        (x86_64_movabs_operand): Don't allow nonmemory_operand for
>        TARGET_X32.

Why? It is certainly not needed for -fPIC. Please provide a separate
patch and testcase for predicates.md change.

Uros.
Index: i386.c
===================================================================
--- i386.c      (revision 176794)
+++ i386.c      (working copy)
@@ -15028,11 +15028,14 @@ ix86_expand_move (enum machine_mode mode
                                     op0, 1, OPTAB_DIRECT);
          if (tmp == op0)
            return;
+         if (GET_MODE (tmp) != mode)
+           op1 = convert_to_mode (mode, tmp, 1);
        }
     }
 
   if ((flag_pic || MACHOPIC_INDIRECT) 
-       && mode == Pmode && symbolic_operand (op1, Pmode))
+      && (mode == SImode || mode == DImode)
+      && symbolic_operand (op1, mode))
     {
       if (TARGET_MACHO && !TARGET_64BIT)
        {
@@ -15073,13 +15076,15 @@ ix86_expand_move (enum machine_mode mode
       else
        {
          if (MEM_P (op0))
-           op1 = force_reg (Pmode, op1);
-         else if (!TARGET_64BIT || !x86_64_movabs_operand (op1, Pmode))
+           op1 = force_reg (mode, op1);
+         else if (!TARGET_64BIT || !x86_64_movabs_operand (op1, mode))
            {
              rtx reg = can_create_pseudo_p () ? NULL_RTX : op0;
              op1 = legitimize_pic_address (op1, reg);
              if (op0 == op1)
                return;
+             if (GET_MODE (op1) != mode)
+               op1 = convert_to_mode (mode, op1, 1);
            }
        }
     }

Reply via email to