Debian Codegraph @

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

raw
1 /* Testing pass avr-ifelse with REG-REG 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, T y) \
31 { \
32 if (x cmp1 y) \
33 f (1); \
34 else if (x cmp2 y) \
35 f (2); \
36 } \
37 \
38 NI char val_##id (T x, T y) \
39 { \
40 char c = 0; \
41 T x2 = x; \
42 __asm ("" : "+r" (x2)); \
43 \
44 if (x cmp1 y) \
45 c += 1; \
46 else if (x2 cmp2 y) \
47 c += 2; \
48 \
49 return c; \
50 }
51
52 MK_FUN (01, >, <)
53 MK_FUN (02, <, >)
54
55 MK_FUN (03, ==, <= )
56 MK_FUN (04, ==, >= )
57
58 MK_FUN (05, ==, <)
59 MK_FUN (06, ==, >)
60
61 MK_FUN (07, >, ==)
62 MK_FUN (08, <, ==)
63
64 MK_FUN (09, >, !=)
65 MK_FUN (10, <, !=)
66
67 void testA (void)
68 {
69 for (T x = (T) (V - 2); x != (T) (V + 2); ++x)
70 {
71 cc = 0; fun_01 (x,V); if (cc != val_01 (x,V)) __builtin_exit (__LINE__);
72 cc = 0; fun_02 (x,V); if (cc != val_02 (x,V)) __builtin_exit (__LINE__);
73 cc = 0; fun_03 (x,V); if (cc != val_03 (x,V)) __builtin_exit (__LINE__);
74 cc = 0; fun_04 (x,V); if (cc != val_04 (x,V)) __builtin_exit (__LINE__);
75 cc = 0; fun_05 (x,V); if (cc != val_05 (x,V)) __builtin_exit (__LINE__);
76 cc = 0; fun_06 (x,V); if (cc != val_06 (x,V)) __builtin_exit (__LINE__);
77 cc = 0; fun_07 (x,V); if (cc != val_07 (x,V)) __builtin_exit (__LINE__);
78 cc = 0; fun_08 (x,V); if (cc != val_08 (x,V)) __builtin_exit (__LINE__);
79 cc = 0; fun_09 (x,V); if (cc != val_09 (x,V)) __builtin_exit (__LINE__);
80 cc = 0; fun_10 (x,V); if (cc != val_10 (x,V)) __builtin_exit (__LINE__);
81 }
82 }
83 #endif /* OPTIMIZE */
84
85 int main (void)
86 {
87 #ifdef __OPTIMIZE__
88 testA();
89 #endif /* OPTIMIZE */
90
91 return 0;
92 }