1/* { dg-do run } */
2/* { dg-options "-O0" } */
3
4#include <x86intrin.h>
5
6#ifdef __x86_64__
7#define EFLAGS_TYPE unsigned long long int
8#else
9#define EFLAGS_TYPE unsigned int
10#endif
11
12__attribute__((noinline, noclone))
13EFLAGS_TYPE
14readeflags_test (unsigned int a, unsigned int b)
15{
16  volatile char x = (a == b);
17  return __readeflags ();
18}
19
20int
21main ()
22{
23  EFLAGS_TYPE flags;
24
25  flags = readeflags_test (100, 100);
26
27  if ((flags & 1) != 0)  /* Read CF */
28    abort ();
29
30  flags = readeflags_test (100, 101);
31
32  if ((flags & 1) == 0)  /* Read CF */
33    abort ();
34
35#ifdef DEBUG
36    printf ("PASSED\n");
37#endif
38
39  return 0;
40}
41
42