Debian Codegraph @

gcc/testsuite/gcc.target/avr/torture/ifelse-d.h

raw
1 /* Testing pass avr-ifelse with REG-CONST_INT comparisons
2 where the 2nd insn is behind the true edge of insn1 (reverse_cond1). */
3
4 #define V ((T) (W))
5
6 #ifdef __OPTIMIZE__
7
8 typedef __UINT32_TYPE__ u32;
9 __extension__ typedef __uint24 u24;
10 typedef __UINT16_TYPE__ u16;
11 typedef __UINT8_TYPE__ u8;
12
13 typedef __INT32_TYPE__ i32;
14 __extension__ typedef __int24 i24;
15 typedef __INT16_TYPE__ i16;
16 typedef __INT8_TYPE__ i8;
17
18 char volatile cc;
19
20 #define NI __attribute__((noipa))
21 #define AI static __inline__ __attribute__((always_inline))
22
23 NI
24 void f (char x)
25 {
26 cc += x;
27 }
28
29 #define MK_FUN(id, cmp1, cmp2) \
30 NI void fun_##id (T x) \
31 { \
32 if (x cmp1) \
33 f (1); \
34 else if (x cmp2) \
35 f (2); \
36 } \
37 \
38 NI char val_##id (T x) \
39 { \
40 char c = 0; \
41 T x2 = x; \
42 __asm ("" : "+r" (x2)); \
43 \
44 if (x cmp1) \
45 c += 1; \
46 else if (x2 cmp2) \
47 c += 2; \
48 \
49 return c; \
50 }
51
52 MK_FUN (01, > V, == V)
53 MK_FUN (02, < V, == V)
54
55 MK_FUN (03, == V, < V)
56 MK_FUN (04, == V, > V)
57
58 MK_FUN (05, > V, != V)
59 MK_FUN (06, < V, != V)
60
61 void testA (void)
62 {
63 for (T x = (T) (V - 2); x != (T) (V + 2); ++x)
64 {
65 cc = 0; fun_01 (x); if (cc != val_01 (x)) __builtin_exit (__LINE__);
66 cc = 0; fun_02 (x); if (cc != val_02 (x)) __builtin_exit (__LINE__);
67 cc = 0; fun_03 (x); if (cc != val_03 (x)) __builtin_exit (__LINE__);
68 cc = 0; fun_04 (x); if (cc != val_04 (x)) __builtin_exit (__LINE__);
69 cc = 0; fun_05 (x); if (cc != val_05 (x)) __builtin_exit (__LINE__);
70 cc = 0; fun_06 (x); if (cc != val_06 (x)) __builtin_exit (__LINE__);
71 }
72 }
73 #endif /* OPTIMIZE */
74
75 int main (void)
76 {
77 #ifdef __OPTIMIZE__
78 testA();
79 #endif /* OPTIMIZE */
80
81 return 0;
82 }