Debian Codegraph @

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

raw
1 /* Testing pass avr-ifelse with REG-REG comparisons. */
2
3 #define V ((T) (W))
4
5 #ifdef __OPTIMIZE__
6
7 typedef __UINT32_TYPE__ u32;
8 __extension__ typedef __uint24 u24;
9 typedef __UINT16_TYPE__ u16;
10 typedef __UINT8_TYPE__ u8;
11
12 typedef __INT32_TYPE__ i32;
13 __extension__ typedef __int24 i24;
14 typedef __INT16_TYPE__ i16;
15 typedef __INT8_TYPE__ i8;
16
17 char volatile cc;
18
19 #define NI __attribute__((noipa))
20 #define AI static __inline__ __attribute__((always_inline))
21
22 NI
23 void f (char x)
24 {
25 cc += x;
26 }
27
28 #define MK_FUN(id, cmp1, cmp2) \
29 NI void fun_##id (T x, T y) \
30 { \
31 if (x cmp1 y) \
32 goto a; \
33 if (x cmp2 y) \
34 goto b; \
35 f(1); \
36 a: \
37 f(2); \
38 b: \
39 f(4); \
40 } \
41 \
42 NI char val_##id (T x, T y) \
43 { \
44 char c = 0; \
45 if (x cmp1 y) \
46 goto a; \
47 __asm ("" : "+r" (x)); \
48 __asm ("" : "+r" (y)); \
49 if (x cmp2 y) \
50 goto b; \
51 c += 1; \
52 a: \
53 c += 2; \
54 b: \
55 c += 4; \
56 \
57 return c; \
58 }
59
60 MK_FUN (01, >, <)
61 MK_FUN (02, <, >)
62
63 MK_FUN (03, ==, <= )
64 MK_FUN (04, ==, >= )
65
66 MK_FUN (05, ==, <)
67 MK_FUN (06, ==, >)
68
69 MK_FUN (07, >, ==)
70 MK_FUN (08, <, ==)
71
72 MK_FUN (09, >, !=)
73 MK_FUN (10, <, !=)
74
75 void testA (void)
76 {
77 for (T x = (T) (V - 2); x != (T) (V + 2); ++x)
78 {
79 cc = 0; fun_01 (x,V); if (cc != val_01 (x,V)) __builtin_exit (__LINE__);
80 cc = 0; fun_02 (x,V); if (cc != val_02 (x,V)) __builtin_exit (__LINE__);
81 cc = 0; fun_03 (x,V); if (cc != val_03 (x,V)) __builtin_exit (__LINE__);
82 cc = 0; fun_04 (x,V); if (cc != val_04 (x,V)) __builtin_exit (__LINE__);
83 cc = 0; fun_05 (x,V); if (cc != val_05 (x,V)) __builtin_exit (__LINE__);
84 cc = 0; fun_06 (x,V); if (cc != val_06 (x,V)) __builtin_exit (__LINE__);
85 cc = 0; fun_07 (x,V); if (cc != val_07 (x,V)) __builtin_exit (__LINE__);
86 cc = 0; fun_08 (x,V); if (cc != val_08 (x,V)) __builtin_exit (__LINE__);
87 cc = 0; fun_09 (x,V); if (cc != val_09 (x,V)) __builtin_exit (__LINE__);
88 cc = 0; fun_10 (x,V); if (cc != val_10 (x,V)) __builtin_exit (__LINE__);
89 }
90 }
91 #endif /* OPTIMIZE */
92
93 int main (void)
94 {
95 #ifdef __OPTIMIZE__
96 testA();
97 #endif /* OPTIMIZE */
98
99 return 0;
100 }