OSDN Git Service

* config/i386/i386.c (legitimate_constant_p): UNSPEC_TP is not
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Aug 2002 00:01:12 +0000 (00:01 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Aug 2002 00:01:12 +0000 (00:01 +0000)
legitimate constant.
(legitimate_pic_operand_p): Neither pic operand.
(legitimate_address_p): But legitimate address.
(get_thread_pointer): Generate MEM/u instead of CONST around
UNSPEC_TP.
(print_operand): Remove printing of UNSPEC_TP.
(print_operand_address): And print it here.

* gcc.dg/tls/opt-2.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@56143 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tls/opt-2.c [new file with mode: 0644]

index 7c22cb6..9e0b085 100644 (file)
@@ -1,4 +1,16 @@
+2002-08-08  Jakub Jelinek  <jakub@redhat.com>
+
+       * config/i386/i386.c (legitimate_constant_p): UNSPEC_TP is not
+       legitimate constant.
+       (legitimate_pic_operand_p): Neither pic operand.
+       (legitimate_address_p): But legitimate address.
+       (get_thread_pointer): Generate MEM/u instead of CONST around
+       UNSPEC_TP.
+       (print_operand): Remove printing of UNSPEC_TP.
+       (print_operand_address): And print it here.
+
 2002-08-08  Devang Patel  <dpatel@apple.com>
 2002-08-08  Devang Patel  <dpatel@apple.com>
+
        * objc/objc-act.c (build_selector_translation_table): Issue warning, 
        when  -Wselector is used,if method for which selector is being 
        created does not exist.
        * objc/objc-act.c (build_selector_translation_table): Issue warning, 
        when  -Wselector is used,if method for which selector is being 
        created does not exist.
index 5ef4e76..0c1ed9f 100644 (file)
@@ -4850,8 +4850,6 @@ legitimate_constant_p (x)
          {
          case UNSPEC_TPOFF:
            return local_exec_symbolic_operand (XVECEXP (inner, 0, 0), Pmode);
          {
          case UNSPEC_TPOFF:
            return local_exec_symbolic_operand (XVECEXP (inner, 0, 0), Pmode);
-         case UNSPEC_TP:
-           return true;
          default:
            return false;
          }
          default:
            return false;
          }
@@ -4914,8 +4912,6 @@ legitimate_pic_operand_p (x)
          {
          case UNSPEC_TPOFF:
            return local_exec_symbolic_operand (XVECEXP (inner, 0, 0), Pmode);
          {
          case UNSPEC_TPOFF:
            return local_exec_symbolic_operand (XVECEXP (inner, 0, 0), Pmode);
-         case UNSPEC_TP:
-           return true;
          default:
            return false;
          }
          default:
            return false;
          }
@@ -5054,6 +5050,13 @@ legitimate_address_p (mode, addr, strict)
       debug_rtx (addr);
     }
 
       debug_rtx (addr);
     }
 
+  if (GET_CODE (addr) == UNSPEC && XINT (addr, 1) == UNSPEC_TP)
+    {
+      if (TARGET_DEBUG_ADDR)
+       fprintf (stderr, "Success.\n");
+      return TRUE;
+    }
+
   if (ix86_decompose_address (addr, &parts) <= 0)
     {
       reason = "decomposition failed";
   if (ix86_decompose_address (addr, &parts) <= 0)
     {
       reason = "decomposition failed";
@@ -5521,7 +5524,9 @@ get_thread_pointer ()
   rtx tp;
 
   tp = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, const0_rtx), UNSPEC_TP);
   rtx tp;
 
   tp = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, const0_rtx), UNSPEC_TP);
-  tp = gen_rtx_CONST (Pmode, tp);
+  tp = gen_rtx_MEM (Pmode, tp);
+  RTX_UNCHANGING_P (tp) = 1;
+  set_mem_alias_set (tp, ix86_GOT_alias_set ());
   tp = force_reg (Pmode, tp);
 
   return tp;
   tp = force_reg (Pmode, tp);
 
   return tp;
@@ -6611,17 +6616,6 @@ print_operand (file, x, code)
       fprintf (file, "%s", dstr);
     }
 
       fprintf (file, "%s", dstr);
     }
 
-  else if (GET_CODE (x) == CONST
-          && GET_CODE (XEXP (x, 0)) == UNSPEC
-          && XINT (XEXP (x, 0), 1) == UNSPEC_TP)
-    {
-      if (ASSEMBLER_DIALECT == ASM_INTEL)
-       fputs ("DWORD PTR ", file);
-      if (ASSEMBLER_DIALECT == ASM_ATT || USER_LABEL_PREFIX[0] == 0)
-       putc ('%', file);
-      fputs ("gs:0", file);
-    }
-
   else
     {
       if (code != 'P')
   else
     {
       if (code != 'P')
@@ -6660,6 +6654,16 @@ print_operand_address (file, addr)
   rtx base, index, disp;
   int scale;
 
   rtx base, index, disp;
   int scale;
 
+  if (GET_CODE (addr) == UNSPEC && XINT (addr, 1) == UNSPEC_TP)
+    {
+      if (ASSEMBLER_DIALECT == ASM_INTEL)
+       fputs ("DWORD PTR ", file);
+      if (ASSEMBLER_DIALECT == ASM_ATT || USER_LABEL_PREFIX[0] == 0)
+       putc ('%', file);
+      fputs ("gs:0", file);
+      return;
+    }
+
   if (! ix86_decompose_address (addr, &parts))
     abort ();
 
   if (! ix86_decompose_address (addr, &parts))
     abort ();
 
index 07c3a50..3e18dc1 100644 (file)
@@ -1,5 +1,10 @@
+2002-08-08  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.dg/tls/opt-2.c: New test.
+
 2002-08-08  Devang Patel  <dpatel@apple.com>
 2002-08-08  Devang Patel  <dpatel@apple.com>
-       *objc.dg/selector-1.m : New test
+
+       * objc.dg/selector-1.m : New test
        
 2002-08-08  Nathan Sidwell  <nathan@codesourcery.com>
 
        
 2002-08-08  Nathan Sidwell  <nathan@codesourcery.com>
 
diff --git a/gcc/testsuite/gcc.dg/tls/opt-2.c b/gcc/testsuite/gcc.dg/tls/opt-2.c
new file mode 100644 (file)
index 0000000..713fb7f
--- /dev/null
@@ -0,0 +1,53 @@
+/* This testcase generated invalid assembly on IA-32,
+   since %gs:0 memory load was not exposed to the compiler
+   as memory load and mem to mem moves are not possible
+   on IA-32.  */
+/* { dg-do link } */
+/* { dg-options "-O2 -ftls-model=initial-exec" } */
+/* { dg-options "-O2 -ftls-model=initial-exec -march=i686" { target i?86-*-* } } */
+
+__thread int thr;
+
+struct A
+{
+  unsigned int a, b, c, d, e;
+};
+
+int bar (int x, unsigned long y, void *z)
+{
+  return 0;
+}
+
+int
+foo (int x, int y, const struct A *z)
+{
+  struct A b;
+  int d;
+
+  b = *z;
+  d = bar (x, y, &b);
+  if (d == 0 && y == 0x5402)
+    {
+      int e = thr;
+      d = bar (x, 0x5401, &b);
+      if (d)
+       {
+         thr = e;
+         d = 0;
+       }
+      else if ((z->c & 0600) != (b.c & 0600)
+              || ((z->c & 060) && ((z->c & 060) != (b.c & 060))))
+       {
+         thr = 22;
+         d = -1;
+       }
+    }
+
+  return d;
+}
+
+int main (void)
+{
+  foo (1, 2, 0);
+  return 0;
+}