Debian Codegraph @

gcc/testsuite/gcc.target/avr/torture/cmp-lsr-i32.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 i32
6
7 #ifdef __OPTIMIZE__
8
9 typedef __INT32_TYPE__ i32;
10 typedef __UINT8_TYPE__ u8;
11 typedef __INT8_TYPE__ i8;
12
13 u8 volatile cc;
14
15 #define NI __attribute__((noipa))
16 #define AI static __inline__ __attribute__((always_inline))
17
18 #define MK_FUN(id, val) \
19 NI void fun_geu_##id (T x) \
20 { \
21 if (x >= val) \
22 cc = 0; \
23 } \
24 \
25 NI T fun_ltu_##id (T x) \
26 { \
27 if (x < val) \
28 cc = 0; \
29 return x; \
30 } \
31 \
32 NI void test_##id (void) \
33 { \
34 for (i8 v = -2; v <= 2; ++v) \
35 { \
36 const u8 lt0 = !! (v & 0x80); \
37 const T x = val + (T) v; \
38 \
39 cc = 1; \
40 fun_geu_##id (x); \
41 if (cc != lt0) \
42 __builtin_exit (__LINE__); \
43 \
44 cc = 1; \
45 T y = fun_ltu_##id (x); \
46 if (y != x) \
47 __builtin_exit (__LINE__); \
48 if (cc != ! lt0) \
49 __builtin_exit (__LINE__); \
50 } \
51 }
52
53 MK_FUN (01, 0x100)
54 MK_FUN (02, 0x1200)
55 MK_FUN (03, 0x8000)
56 MK_FUN (04, 0x10000)
57 MK_FUN (05, 0x110000)
58 MK_FUN (06, 0x1000000)
59 MK_FUN (07, -256)
60 MK_FUN (08, -512)
61 MK_FUN (09, -32000)
62 MK_FUN (10, -0x40000000)
63
64 #endif /* OPTIMIZE */
65
66 int main (void)
67 {
68 #ifdef __OPTIMIZE__
69 test_01 ();
70 test_02 ();
71 test_03 ();
72 test_04 ();
73 test_05 ();
74 test_06 ();
75 test_07 ();
76 test_08 ();
77 test_09 ();
78 test_10 ();
79 #endif /* OPTIMIZE */
80
81 return 0;
82 }