Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / gcc.dg / tls / opt-2.c
blob8038d1c6ffb74e42f95cf544bdef7d004d41d4ee
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 } */
10 __thread int thr;
12 struct A
14 unsigned int a, b, c, d, e;
17 int bar (int x, unsigned long y, void *z)
19 return 0;
22 int
23 foo (int x, int y, const struct A *z)
25 struct A b;
26 int d;
28 b = *z;
29 d = bar (x, y, &b);
30 if (d == 0 && y == 0x5402)
32 int e = thr;
33 d = bar (x, 0x5401, &b);
34 if (d)
36 thr = e;
37 d = 0;
39 else if ((z->c & 0600) != (b.c & 0600)
40 || ((z->c & 060) && ((z->c & 060) != (b.c & 060))))
42 thr = 22;
43 d = -1;
47 return d;
50 int main (void)
52 foo (1, 2, 0);
53 return 0;