2017-12-05 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / pr57154.c
blob6e436befe9da4fd7f486dc6570fdb68dc3b92f66
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fschedule-insns" } */
3 /* { dg-require-effective-target scheduling } */
5 #define PF_FROZEN 0x00010000
6 #define likely(x) __builtin_expect(!!(x), 1)
8 struct cur
10 unsigned long flags;
12 struct cur *cur;
14 unsigned long freeze_cnt;
16 extern int foo(void *);
17 extern int slow_path(void *);
19 static inline int freezing(void *p)
21 if (likely(!foo(&freeze_cnt)))
22 return 0;
23 return slow_path(p);
26 extern int blah(void);
28 int testcase(int check_kthr_stop)
30 int was_frozen = 0;
32 for (;;) {
33 if (!freezing(cur) ||
34 (check_kthr_stop && blah()))
35 cur->flags &= ~PF_FROZEN;
37 if (!(cur->flags & PF_FROZEN))
38 break;
40 was_frozen = 1;
43 return was_frozen;