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