OSDN Git Service

8038d1c6ffb74e42f95cf544bdef7d004d41d4ee
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / tls / opt-2.c
1 /* This testcase generated invalid assembly on IA-32,
2    since %gs:0 memory load was not exposed to the compiler
3    as memory load and mem to mem moves are not possible
4    on IA-32.  */
5 /* { dg-do link } */
6 /* { dg-options "-O2 -ftls-model=initial-exec" } */
7 /* { dg-options "-O2 -ftls-model=initial-exec -march=i686" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
8 /* { dg-require-effective-target tls_native } */
9
10 __thread int thr;
11
12 struct A
13 {
14   unsigned int a, b, c, d, e;
15 };
16
17 int bar (int x, unsigned long y, void *z)
18 {
19   return 0;
20 }
21
22 int
23 foo (int x, int y, const struct A *z)
24 {
25   struct A b;
26   int d;
27
28   b = *z;
29   d = bar (x, y, &b);
30   if (d == 0 && y == 0x5402)
31     {
32       int e = thr;
33       d = bar (x, 0x5401, &b);
34       if (d)
35         {
36           thr = e;
37           d = 0;
38         }
39       else if ((z->c & 0600) != (b.c & 0600)
40                || ((z->c & 060) && ((z->c & 060) != (b.c & 060))))
41         {
42           thr = 22;
43           d = -1;
44         }
45     }
46
47   return d;
48 }
49
50 int main (void)
51 {
52   foo (1, 2, 0);
53   return 0;
54 }