| 1 |
/* Test comparisons against constants that are a multiple of 256. */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-additional-options { -std=c99 } } */ |
| 4 |
|
| 5 |
#define T u24 |
| 6 |
|
| 7 |
#ifdef __OPTIMIZE__ |
| 8 |
|
| 9 |
typedef __UINT64_TYPE__ u64; |
| 10 |
typedef __UINT32_TYPE__ u32; |
| 11 |
typedef __uint24 u24; |
| 12 |
typedef __UINT16_TYPE__ u16; |
| 13 |
typedef __UINT8_TYPE__ u8; |
| 14 |
|
| 15 |
typedef __INT8_TYPE__ i8; |
| 16 |
|
| 17 |
u8 volatile cc; |
| 18 |
|
| 19 |
#define NI __attribute__((noipa)) |
| 20 |
#define AI static __inline__ __attribute__((always_inline)) |
| 21 |
|
| 22 |
#define MK_FUN(id, val) \ |
| 23 |
NI void fun_geu_##id (T x) \ |
| 24 |
{ \ |
| 25 |
if (x >= val) \ |
| 26 |
cc = 0; \ |
| 27 |
} \ |
| 28 |
\ |
| 29 |
NI T fun_ltu_##id (T x) \ |
| 30 |
{ \ |
| 31 |
if (x < val) \ |
| 32 |
cc = 0; \ |
| 33 |
return x; \ |
| 34 |
} \ |
| 35 |
\ |
| 36 |
NI void test_##id (void) \ |
| 37 |
{ \ |
| 38 |
for (i8 v = -2; v <= 2; ++v) \ |
| 39 |
{ \ |
| 40 |
const u8 lt0 = !! (v & 0x80); \ |
| 41 |
const T x = val + (T) v; \ |
| 42 |
\ |
| 43 |
cc = 1; \ |
| 44 |
fun_geu_##id (x); \ |
| 45 |
if (cc != lt0) \ |
| 46 |
__builtin_exit (__LINE__); \ |
| 47 |
\ |
| 48 |
cc = 1; \ |
| 49 |
T y = fun_ltu_##id (x); \ |
| 50 |
if (y != x) \ |
| 51 |
__builtin_exit (__LINE__); \ |
| 52 |
if (cc != ! lt0) \ |
| 53 |
__builtin_exit (__LINE__); \ |
| 54 |
} \ |
| 55 |
} |
| 56 |
|
| 57 |
MK_FUN (01, 0x100) |
| 58 |
MK_FUN (02, 0x1200) |
| 59 |
MK_FUN (03, 0x8000) |
| 60 |
MK_FUN (04, 0x10000) |
| 61 |
MK_FUN (05, 0x110000) |
| 62 |
|
| 63 |
#endif /* OPTIMIZE */ |
| 64 |
|
| 65 |
int main (void) |
| 66 |
{ |
| 67 |
#ifdef __OPTIMIZE__ |
| 68 |
test_01 (); |
| 69 |
test_02 (); |
| 70 |
test_03 (); |
| 71 |
test_04 (); |
| 72 |
test_05 (); |
| 73 |
#endif /* OPTIMIZE */ |
| 74 |
|
| 75 |
return 0; |
| 76 |
} |