OSDN Git Service

* config/ia64/ia64.c (ia64_expand_tls_address): Add ORIG_OP1 argument.
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Nov 2005 08:32:16 +0000 (08:32 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Nov 2005 08:32:16 +0000 (08:32 +0000)
Move ADDEND_{HI,LO} computation into TLS_MODEL_INITIAL_EXEC case.
(ia64_expand_move): Adjust caller.

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

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

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

index b7067e9..4c2e7be 100644 (file)
@@ -1,5 +1,9 @@
 2005-11-30  Jakub Jelinek  <jakub@redhat.com>
 
+       * config/ia64/ia64.c (ia64_expand_tls_address): Add ORIG_OP1 argument.
+       Move ADDEND_{HI,LO} computation into TLS_MODEL_INITIAL_EXEC case.
+       (ia64_expand_move): Adjust caller.
+
        * config/ia64/ia64.c (ia64_expand_atomic_op): Only use
        fetchadd{4,8}.acq instruction if CODE is PLUS or MINUS, for MINUS
        negate VAL.
index a07cc6e..95a4cdb 100644 (file)
@@ -891,15 +891,12 @@ gen_thread_pointer (void)
 
 static rtx
 ia64_expand_tls_address (enum tls_model tls_kind, rtx op0, rtx op1,
-                        HOST_WIDE_INT addend)
+                        rtx orig_op1, HOST_WIDE_INT addend)
 {
   rtx tga_op1, tga_op2, tga_ret, tga_eqv, tmp, insns;
-  rtx orig_op0 = op0, orig_op1 = op1;
+  rtx orig_op0 = op0;
   HOST_WIDE_INT addend_lo, addend_hi;
 
-  addend_lo = ((addend & 0x3fff) ^ 0x2000) - 0x2000;
-  addend_hi = addend - addend_lo;
-
   switch (tls_kind)
     {
     case TLS_MODEL_GLOBAL_DYNAMIC:
@@ -959,6 +956,9 @@ ia64_expand_tls_address (enum tls_model tls_kind, rtx op0, rtx op1,
       break;
 
     case TLS_MODEL_INITIAL_EXEC:
+      addend_lo = ((addend & 0x3fff) ^ 0x2000) - 0x2000;
+      addend_hi = addend - addend_lo;
+
       op1 = plus_constant (op1, addend_hi);
       addend = addend_lo;
 
@@ -1023,7 +1023,7 @@ ia64_expand_move (rtx op0, rtx op1)
 
       tls_kind = tls_symbolic_operand_type (sym);
       if (tls_kind)
-       return ia64_expand_tls_address (tls_kind, op0, sym, addend);
+       return ia64_expand_tls_address (tls_kind, op0, sym, op1, addend);
 
       if (any_offset_symbol_operand (sym, mode))
        addend = 0;
index 4d9d5da..57ea16d 100644 (file)
@@ -1,3 +1,7 @@
+2005-11-30  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.dg/tls/opt-11.c: New test.
+
 2005-11-29  Joseph S. Myers  <joseph@codesourcery.com>
 
        * gcc.dg/torture/fp-int-convert-timode.c: XFAIL only on lp64
diff --git a/gcc/testsuite/gcc.dg/tls/opt-11.c b/gcc/testsuite/gcc.dg/tls/opt-11.c
new file mode 100644 (file)
index 0000000..5b2cd5c
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+
+extern void abort (void);
+extern void *memset (void *, int, __SIZE_TYPE__);
+
+struct A
+{
+  char pad[48];
+  int i;
+  int pad2;
+  int j;
+};
+__thread struct A a;
+
+int *
+__attribute__((noinline))
+foo (void)
+{
+  return &a.i;
+}
+
+int
+main (void)
+{
+  int *p = foo ();
+  memset (&a, 0, sizeof (a));
+  a.i = 6;
+  a.j = 8;
+  if (p[0] != 6 || p[1] != 0 || p[2] != 8)
+    abort ();
+  return 0;
+}