| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O" } */ |
| 3 |
|
| 4 |
extern void link_error (void); |
| 5 |
unsigned int __attribute__((noinline,noclone)) |
| 6 |
test0 (unsigned int a) |
| 7 |
{ |
| 8 |
a = a & 1; |
| 9 |
a = a << 1 | a >> (sizeof (unsigned int) * 8 - 1); |
| 10 |
if (a & 1) |
| 11 |
{ |
| 12 |
a = a | 4; |
| 13 |
link_error (); |
| 14 |
} |
| 15 |
if (a & 4) |
| 16 |
link_error (); |
| 17 |
return a; |
| 18 |
} |
| 19 |
int __attribute__((noinline,noclone)) |
| 20 |
test1 (int a) |
| 21 |
{ |
| 22 |
a |= 1; |
| 23 |
a = a << (sizeof (int) * 8 - 1); |
| 24 |
if (a >= 0) |
| 25 |
link_error (); |
| 26 |
a = a * 4; |
| 27 |
if (a & ~3) |
| 28 |
link_error (); |
| 29 |
if (a == -1) |
| 30 |
link_error (); |
| 31 |
return a; |
| 32 |
} |
| 33 |
int __attribute__((noinline,noclone)) |
| 34 |
test2 (int a) |
| 35 |
{ |
| 36 |
a = a | 0xff; |
| 37 |
a = a + 1; |
| 38 |
if (a & 0xff) |
| 39 |
link_error (); |
| 40 |
a = -a; |
| 41 |
if (a & 0xff) |
| 42 |
link_error (); |
| 43 |
a = a - 1; |
| 44 |
if ((a & 0xff) != 0xff) |
| 45 |
link_error (); |
| 46 |
return a; |
| 47 |
} |
| 48 |
extern void abort (void); |
| 49 |
int main() |
| 50 |
{ |
| 51 |
if (test0 (1) != 2) |
| 52 |
abort (); |
| 53 |
if (test1 (0) != 0) |
| 54 |
abort (); |
| 55 |
if (test2 (-1) != -1) |
| 56 |
abort (); |
| 57 |
return 0; |
| 58 |
} |