2018-02-09 Sebastian Perta <sebastian.perta@renesas.com>
[official-gcc.git] / gcc / testsuite / gcc.target / sh / pr54760-3.c
blob617a66ba6755471047b20d158077b8598077946b
1 /* Check that these thread relative memory accesses play along with
2 surrounding code.
3 These should be moved to C torture tests once there are target
4 independent thread_pointer built-in functions available. */
5 /* { dg-do compile } */
6 /* { dg-options "-O1" } */
8 int
9 test00 (void* p, int x)
11 int* tcb = (int*)__builtin_thread_pointer ();
12 int r = tcb[4];
14 __builtin_set_thread_pointer (p);
16 tcb = (int*)__builtin_thread_pointer ();
17 return tcb[255] + r;
20 int
21 test01 (void)
23 unsigned short* tcb = (unsigned short*)__builtin_thread_pointer ();
24 return tcb[500];
27 void
28 test02 (int* x, int a, int b)
30 int* tcb = (int*)__builtin_thread_pointer ();
31 tcb[50] = a;
33 __builtin_set_thread_pointer (x);
35 tcb = (int*)__builtin_thread_pointer ();
36 tcb[40] = b;
39 int
40 test03 (const int* x, int c)
42 volatile int* tcb = (volatile int*)__builtin_thread_pointer ();
44 int s = 0;
45 int i;
46 for (i = 0; i < c; ++i)
47 s ^= x[i] + tcb[40];
49 return s;
52 int
53 test04 (const int* x, int c, int** xx, int d)
55 int s = 0;
56 int i;
57 for (i = 0; i < c; ++i)
59 volatile int* tcb = (volatile int*)__builtin_thread_pointer ();
60 tcb[20] = s;
62 __builtin_set_thread_pointer (xx[i]);
64 tcb = (volatile int*)__builtin_thread_pointer ();
65 s ^= x[i] + tcb[40] + d;
67 return s;