* gcc-interface/trans.c (node_has_volatile_full_access) <N_Identifier>:
[official-gcc.git] / gcc / testsuite / gcc.c-torture / compile / pr78694.c
blobbc3194426a0d91928c03dad23747993c3acabc5a
1 /* PR target/78694. */
3 enum
5 MEMMODEL_RELAXED,
6 MEMMODEL_ACQUIRE,
7 PRIORITY_INSERT_END
8 };
9 enum
11 PQ_CHILDREN,
12 PQ_TASKGROUP
14 struct gomp_team_state
16 struct gomp_team *team;
18 enum gomp_task_kind
20 GOMP_TASK_UNDEFERRED,
21 GOMP_TASK_WAITING
23 struct gomp_taskwait
25 _Bool in_taskwait;
27 struct gomp_task
29 struct gomp_task *parent;
30 int children_queue;
31 struct gomp_taskgroup *taskgroup;
32 int dependers;
33 struct gomp_taskwait taskwait;
34 enum gomp_task_kind kind;
35 _Bool in_tied_task;
36 } j, q, *n;
37 struct gomp_taskgroup
39 _Bool in_taskgroup_wait;
40 int num_children;
41 } l;
42 struct gomp_team
44 int task_queue;
45 int task_running_count;
47 struct gomp_thread
49 struct gomp_team_state ts;
50 struct gomp_task task;
51 } extern __thread a;
53 int b, c, d, e, f, g, h, i, k, m, o, p, r;
55 void priority_queue_next_task (struct gomp_task *, int, int);
56 int gomp_task_run_pre (struct gomp_task *, struct gomp_task, struct gomp_team);
57 void priority_queue_insert (int, struct gomp_task);
58 void priority_queue_insert2 (int, struct gomp_task, int, int, int);
59 void priority_queue_insert3 (int, struct gomp_task, int, int, int);
60 void gomp_sem_post (int);
61 void free (void *);
63 _Bool s;
64 int
65 GOMP_taskgroup_end ()
67 struct gomp_thread *t = &a;
68 struct gomp_team u = *t->ts.team;
69 struct gomp_task *v = &t->task, *w;
70 if (__atomic_load_n (&l.num_children, MEMMODEL_ACQUIRE))
71 while (1)
73 if (l.num_children)
74 priority_queue_next_task (v, u.task_queue, r);
75 else if (w)
76 free (w);
77 if (n->kind == GOMP_TASK_WAITING)
79 s = gomp_task_run_pre (n, q, u);
80 if (__builtin_expect (s, 0))
82 if (w)
83 free (w);
84 goto finish_cancelled;
86 n = 0;
87 l.in_taskgroup_wait = 1;
89 if (w)
91 t->task = *n;
92 if (__builtin_expect (p, 0))
93 if (o)
94 t->task = *v;
96 if (n)
98 struct gomp_task x = x;
99 for (; i; b++)
101 struct gomp_task y = j;
102 if (g)
103 continue;
104 priority_queue_insert (PQ_CHILDREN, x);
105 if (x.taskwait.in_taskwait)
106 priority_queue_insert2 (PQ_TASKGROUP, y, e, 0, d);
107 if (h)
108 gomp_sem_post (f);
109 priority_queue_insert3 (k, y, PRIORITY_INSERT_END, 0, d);
110 ++c;
113 finish_cancelled:
114 w = (struct gomp_task *) (n - u.task_running_count - v);
116 v->taskgroup = (struct gomp_taskgroup *) m;
117 return 1;