Debian Codegraph @

gcc/testsuite/gcc.target/avr/pr115830-sub.c

raw
1 /* { dg-do run } */
2 /* { dg-additional-options { -std=c99 -Os } } */
3
4 typedef __UINT8_TYPE__ u8;
5 typedef __INT8_TYPE__ i8;
6 typedef __UINT16_TYPE__ u16;
7 typedef __INT16_TYPE__ i16;
8 __extension__ typedef __uint24 u24;
9 __extension__ typedef __int24 i24;
10 typedef __UINT32_TYPE__ u32;
11 typedef __INT32_TYPE__ i32;
12
13 #define AI static inline __attribute__((always_inline))
14 #define NI __attribute__((noipa))
15
16 u8 volatile v;
17 u8 v1;
18
19 #define MK_FUN(TYP, OP, TST) \
20 NI TYP sub1_##TYP##_##OP (TYP a, TYP b) \
21 { \
22 a -= b; \
23 if (a TST) \
24 v = 0; \
25 return a; \
26 } \
27 \
28 NI TYP sub2_##TYP##_##OP (TYP a, TYP b) \
29 { \
30 a -= b; \
31 __asm ("" : "+r" (a)); \
32 if (a TST) \
33 v = 0; \
34 return a; \
35 } \
36 \
37 NI void test_##TYP##_##OP (TYP a, TYP b)\
38 { \
39 v = 1; \
40 TYP c1 = sub1_##TYP##_##OP (a, b); \
41 v1 = v; \
42 v = 1; \
43 TYP c2 = sub2_##TYP##_##OP (a, b); \
44 if (c1 != c2) \
45 __builtin_abort(); \
46 if (v1 != v) \
47 __builtin_abort(); \
48 }
49
50 MK_FUN (i8, ge, >= 0)
51 MK_FUN (i16, ge, >= 0)
52 MK_FUN (i24, ge, >= 0)
53 MK_FUN (i32, ge, >= 0)
54
55 MK_FUN (i8, lt, < 0)
56 MK_FUN (i16, lt, < 0)
57 MK_FUN (i24, lt, < 0)
58 MK_FUN (i32, lt, < 0)
59
60 MK_FUN (i8, le, <= 0)
61 MK_FUN (i16, le, <= 0)
62 MK_FUN (i24, le, <= 0)
63 MK_FUN (i32, le, <= 0)
64
65 MK_FUN (i8, gt, > 0)
66 MK_FUN (i16, gt, > 0)
67 MK_FUN (i24, gt, > 0)
68 MK_FUN (i32, gt, > 0)
69
70
71 int main (void)
72 {
73 for (i8 a = -5; a <= 5; ++a)
74 {
75 for (i8 b = -5; b <= 5; ++b)
76 {
77 test_i8_ge (a, b);
78 test_i16_ge (a, b);
79 test_i24_ge (a, b);
80 test_i32_ge (a, b);
81
82 test_i8_lt (a, b);
83 test_i16_lt (a, b);
84 test_i24_lt (a, b);
85 test_i32_lt (a, b);
86
87 test_i8_gt (a, b);
88 test_i16_gt (a, b);
89 test_i24_gt (a, b);
90 test_i32_gt (a, b);
91
92 test_i8_le (a, b);
93 test_i16_le (a, b);
94 test_i24_le (a, b);
95 test_i32_le (a, b);
96 }
97 }
98
99 return 0;
100 }