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-*-* } && ia32 } } } */
8 /* { dg-require-effective-target tls } */
9 /* { dg-require-effective-target tls_runtime } */
10
11 __thread int thr;
12
13 struct A
14 {
15 unsigned int a, b, c, d, e;
16 };
17
18 int bar (int x, unsigned long y, void *z)
19 {
20 return 0;
21 }
22
23 int
24 foo (int x, int y, const struct A *z)
25 {
26 struct A b;
27 int d;
28
29 b = *z;
30 d = bar (x, y, &b);
31 if (d == 0 && y == 0x5402)
32 {
33 int e = thr;
34 d = bar (x, 0x5401, &b);
35 if (d)
36 {
37 thr = e;
38 d = 0;
39 }
40 else if ((z->c & 0600) != (b.c & 0600)
41 || ((z->c & 060) && ((z->c & 060) != (b.c & 060))))
42 {
43 thr = 22;
44 d = -1;
45 }
46 }
47
48 return d;
49 }
50
51 int main (void)
52 {
53 foo (1, 2, 0);
54 return 0;
55 }