Debian Codegraph @

gcc/testsuite/gcc.target/avr/torture/cmp-lsr-u64.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 u64
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 MK_FUN (06, 0x1000000)
63 MK_FUN (07, 0x8080000000000000)
64 MK_FUN (08, 0x0100000000000000)
65 MK_FUN (09, 0x0001000000000000)
66
67 #endif /* OPTIMIZE */
68
69 int main (void)
70 {
71 #ifdef __OPTIMIZE__
72 test_01 ();
73 test_02 ();
74 test_03 ();
75 test_04 ();
76 test_05 ();
77 test_06 ();
78 test_07 ();
79 test_08 ();
80 test_09 ();
81 #endif /* OPTIMIZE */
82
83 return 0;
84 }