85bfab144c008b4562c35555e6adf31335ec8c59
[gcc.git] / gcc / testsuite / gcc.target / arm / pr81863.c
1 /* testsuite/gcc.target/arm/pr48183.c */
2 /* { dg-do compile } */
3 /* { dg-skip-if "-mslow-flash-data and -mword-relocations incompatible" { *-*-* } { "-mslow-flash-data" } } */
4 /* { dg-skip-if "-mpure-code and -mword-relocations incompatible" { *-*-* } { "-mpure-code" } } */
5 /* { dg-options "-O2 -mword-relocations -march=armv7-a -marm" } */
6 /* { dg-final { scan-assembler-not "\[\\t \]+movw" } } */
7
8 int a, d, f;
9 long b;
10 struct ww_class {
11 int stamp;
12 } c;
13 struct stress {
14 int locks;
15 int nlocks;
16 };
17 void *e;
18 int atomic_add_return_relaxed(int *p1) {
19 __builtin_prefetch(p1);
20 return a;
21 }
22 void atomic_long_inc_return_relaxed(int *p1) {
23 int *v = p1;
24 atomic_add_return_relaxed(v);
25 }
26 void ww_acquire_init(struct ww_class *p1) {
27 atomic_long_inc_return_relaxed(&p1->stamp);
28 }
29 void ww_mutex_lock();
30 int *get_random_order();
31 void stress_inorder_work() {
32 struct stress *g = e;
33 int h = g->nlocks;
34 int *i = &g->locks, *j = get_random_order();
35 do {
36 int n;
37 ww_acquire_init(&c);
38 retry:
39 for (n = 0; n < h; n++)
40 ww_mutex_lock(i[j[n]]);
41 f = n;
42 if (d)
43 goto retry;
44 } while (b);
45 }
46