Debian Codegraph @

gcc/testsuite/gcc.target/avr/torture/cmp-lsr-u16.c

raw
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 u16
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, 0xff00)
61
62 #endif /* OPTIMIZE */
63
64 int main (void)
65 {
66 #ifdef __OPTIMIZE__
67 test_01 ();
68 test_02 ();
69 test_03 ();
70 #endif /* OPTIMIZE */
71
72 return 0;
73 }