Hi!

On x86_64 with -mcmodel=large -fpic -g -O2 we get tons of
notes about non-delegitimized unspecs like UNSPEC_GOTOFF, UNSPEC_PLTOFF
or UNSPEC_GOT.  Seems we already handle most of those properly for -m32
code, so the issue is just that we wouldn't fall back into the -m32 handling
code which takes care of dealing with addends, missing pic pointer etc.
The following patch inverts the last condition for TARGET_64BIT code
and falls through for CM_MEDIUM_PIC and CM_LARGE_PIC cmodels.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2013-08-13  Jakub Jelinek  <ja...@redhat.com>
            Alexandre Oliva  <aol...@redhat.com>

        PR target/58067
        * config/i386/i386.c (ix86_delegitimize_address): For CM_MEDIUM_PIC
        and CM_LARGE_PIC ix86_cmodel fall thru into the -m32 code, handle
        there also UNSPEC_PLTOFF.

--- gcc/config/i386/i386.c.jj   2013-08-13 14:42:32.000000000 +0200
+++ gcc/config/i386/i386.c      2013-08-13 18:49:25.514219094 +0200
@@ -14135,21 +14135,29 @@ ix86_delegitimize_address (rtx x)
            x = replace_equiv_address_nv (orig_x, x);
          return x;
        }
-      if (GET_CODE (x) != CONST
-         || GET_CODE (XEXP (x, 0)) != UNSPEC
-         || (XINT (XEXP (x, 0), 1) != UNSPEC_GOTPCREL
-             && XINT (XEXP (x, 0), 1) != UNSPEC_PCREL)
-         || (!MEM_P (orig_x) && XINT (XEXP (x, 0), 1) != UNSPEC_PCREL))
-       return ix86_delegitimize_tls_address (orig_x);
-      x = XVECEXP (XEXP (x, 0), 0, 0);
-      if (GET_MODE (orig_x) != GET_MODE (x) && MEM_P (orig_x))
+
+      if (GET_CODE (x) == CONST
+         && GET_CODE (XEXP (x, 0)) == UNSPEC
+         && (XINT (XEXP (x, 0), 1) == UNSPEC_GOTPCREL
+             || XINT (XEXP (x, 0), 1) == UNSPEC_PCREL)
+         && (MEM_P (orig_x) || XINT (XEXP (x, 0), 1) == UNSPEC_PCREL))
        {
-         x = simplify_gen_subreg (GET_MODE (orig_x), x,
-                                  GET_MODE (x), 0);
-         if (x == NULL_RTX)
-           return orig_x;
+         x = XVECEXP (XEXP (x, 0), 0, 0);
+         if (GET_MODE (orig_x) != GET_MODE (x) && MEM_P (orig_x))
+           {
+             x = simplify_gen_subreg (GET_MODE (orig_x), x,
+                                      GET_MODE (x), 0);
+             if (x == NULL_RTX)
+               return orig_x;
+           }
+         return x;
        }
-      return x;
+
+      if (ix86_cmodel != CM_MEDIUM_PIC && ix86_cmodel != CM_LARGE_PIC)
+       return ix86_delegitimize_tls_address (orig_x);
+
+      /* Fall thru into the code shared with -m32 for -mcmodel=large -fpic
+        and -mcmodel=medium -fpic.  */
     }
 
   if (GET_CODE (x) != PLUS
@@ -14186,10 +14194,12 @@ ix86_delegitimize_address (rtx x)
 
   if (GET_CODE (x) == UNSPEC
       && ((XINT (x, 1) == UNSPEC_GOT && MEM_P (orig_x) && !addend)
-         || (XINT (x, 1) == UNSPEC_GOTOFF && !MEM_P (orig_x))))
+         || (XINT (x, 1) == UNSPEC_GOTOFF && !MEM_P (orig_x))
+         || (XINT (x, 1) == UNSPEC_PLTOFF && ix86_cmodel == CM_LARGE_PIC
+             && !MEM_P (orig_x) && !addend)))
     result = XVECEXP (x, 0, 0);
 
-  if (TARGET_MACHO && darwin_local_data_pic (x)
+  if (!TARGET_64BIT && TARGET_MACHO && darwin_local_data_pic (x)
       && !MEM_P (orig_x))
     result = XVECEXP (x, 0, 0);
 

        Jakub

Reply via email to