| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-additional-options { -std=c99 -fwrapv -Os } } */ |
| 3 |
|
| 4 |
typedef __UINT32_TYPE__ uint32_t; |
| 5 |
typedef __INT32_TYPE__ int32_t; |
| 6 |
|
| 7 |
#define AI static inline __attribute__((always_inline)) |
| 8 |
#define NI __attribute__((noipa)) |
| 9 |
|
| 10 |
#define TYP int32_t |
| 11 |
|
| 12 |
TYP volatile v; |
| 13 |
|
| 14 |
#define MK_FUN(ID, OP, TST) \ |
| 15 |
NI TYP func1_##ID (TYP c) \ |
| 16 |
{ \ |
| 17 |
v = 0x77665544; \ |
| 18 |
c OP; \ |
| 19 |
if (c TST) \ |
| 20 |
v = c; \ |
| 21 |
return v; \ |
| 22 |
} \ |
| 23 |
\ |
| 24 |
NI TYP func2_##ID (TYP c) \ |
| 25 |
{ \ |
| 26 |
TYP v = 0x77665544; \ |
| 27 |
c OP; \ |
| 28 |
__asm ("" : "+r" (c)); \ |
| 29 |
if (c TST) \ |
| 30 |
v = c; \ |
| 31 |
return v; \ |
| 32 |
} |
| 33 |
|
| 34 |
MK_FUN (ASL_03, <<= 1, >= 0) |
| 35 |
MK_FUN (ASL_06, <<= 1, < 0) |
| 36 |
|
| 37 |
NI void test_asl (uint32_t c) |
| 38 |
{ |
| 39 |
if (func1_ASL_03 (c) != func2_ASL_03 (c)) __builtin_exit (__LINE__); |
| 40 |
if (func1_ASL_06 (c) != func2_ASL_06 (c)) __builtin_exit (__LINE__); |
| 41 |
} |
| 42 |
|
| 43 |
int main (void) |
| 44 |
{ |
| 45 |
test_asl (0); |
| 46 |
test_asl (0x80000000); |
| 47 |
test_asl (0x80000001); |
| 48 |
test_asl (0xc0000000); |
| 49 |
test_asl (0xc0000001); |
| 50 |
test_asl (0); |
| 51 |
test_asl (0xff00ff00); |
| 52 |
test_asl (0x00ff00ff); |
| 53 |
test_asl (0xff00ff00 >> 1); |
| 54 |
test_asl (0x00ff00ff >> 1); |
| 55 |
|
| 56 |
return 0; |
| 57 |
} |