1 2002-08-08 Jakub Jelinek <jakub@redhat.com>
3 * config/i386/i386.c (legitimate_constant_p): UNSPEC_TP is not
5 (legitimate_pic_operand_p): Neither pic operand.
6 (legitimate_address_p): But legitimate address.
7 (get_thread_pointer): Generate MEM/u instead of CONST around
9 (print_operand): Remove printing of UNSPEC_TP.
10 (print_operand_address): And print it here.
12 * gcc.dg/tls/opt-2.c: New test.
14 --- gcc/config/i386/i386.c.jj 2002-08-07 22:18:39.000000000 +0200
15 +++ gcc/config/i386/i386.c 2002-08-08 18:18:18.000000000 +0200
19 return local_exec_symbolic_operand (XVECEXP (inner, 0, 0), Pmode);
28 return local_exec_symbolic_operand (XVECEXP (inner, 0, 0), Pmode);
34 @@ -5048,6 +5044,13 @@
38 + if (GET_CODE (addr) == UNSPEC && XINT (addr, 1) == UNSPEC_TP)
40 + if (TARGET_DEBUG_ADDR)
41 + fprintf (stderr, "Success.\n");
45 if (ix86_decompose_address (addr, &parts) <= 0)
47 reason = "decomposition failed";
51 tp = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, const0_rtx), UNSPEC_TP);
52 - tp = gen_rtx_CONST (Pmode, tp);
53 + tp = gen_rtx_MEM (Pmode, tp);
54 + RTX_UNCHANGING_P (tp) = 1;
55 + set_mem_alias_set (tp, ix86_GOT_alias_set ());
56 tp = force_reg (Pmode, tp);
59 @@ -6613,17 +6618,6 @@
60 fprintf (file, "%s", dstr);
63 - else if (GET_CODE (x) == CONST
64 - && GET_CODE (XEXP (x, 0)) == UNSPEC
65 - && XINT (XEXP (x, 0), 1) == UNSPEC_TP)
67 - if (ASSEMBLER_DIALECT == ASM_INTEL)
68 - fputs ("DWORD PTR ", file);
69 - if (ASSEMBLER_DIALECT == ASM_ATT || USER_LABEL_PREFIX[0] == 0)
71 - fputs ("gs:0", file);
77 @@ -6662,6 +6656,16 @@
78 rtx base, index, disp;
81 + if (GET_CODE (addr) == UNSPEC && XINT (addr, 1) == UNSPEC_TP)
83 + if (ASSEMBLER_DIALECT == ASM_INTEL)
84 + fputs ("DWORD PTR ", file);
85 + if (ASSEMBLER_DIALECT == ASM_ATT || USER_LABEL_PREFIX[0] == 0)
87 + fputs ("gs:0", file);
91 if (! ix86_decompose_address (addr, &parts))
93 output_operand_lossage ("Wrong address expression or operand constraint");
94 --- gcc/testsuite/gcc.dg/tls/opt-2.c.jj 2002-08-08 18:36:32.000000000 +0200
95 +++ gcc/testsuite/gcc.dg/tls/opt-2.c 2002-08-08 18:34:44.000000000 +0200
97 +/* This testcase generated invalid assembly on IA-32,
98 + since %gs:0 memory load was not exposed to the compiler
99 + as memory load and mem to mem moves are not possible
101 +/* { dg-do link } */
102 +/* { dg-options "-O2 -ftls-model=initial-exec" } */
103 +/* { dg-options "-O2 -ftls-model=initial-exec -march=i686" { target i?86-*-* } } */
109 + unsigned int a, b, c, d, e;
112 +int bar (int x, unsigned long y, void *z)
118 +foo (int x, int y, const struct A *z)
124 + d = bar (x, y, &b);
125 + if (d == 0 && y == 0x5402)
128 + d = bar (x, 0x5401, &b);
134 + else if ((z->c & 0600) != (b.c & 0600)
135 + || ((z->c & 060) && ((z->c & 060) != (b.c & 060))))