Debian Codegraph @

gcc/testsuite/gcc.target/avr/torture/insv-anyshift-si.c

raw
1 /* { dg-do run } */
2
3 typedef __UINT32_TYPE__ uint32_t;
4
5 /* Testing inlined and completely folded versions of functions
6 against their non-inlined, non-folded counnterparts. */
7
8 #define MK_FUN1(OBIT, LSR) \
9 static __inline__ __attribute__((__always_inline__)) \
10 uint32_t fun1_lsr_##OBIT##_##LSR##_ai (int x, uint32_t a) \
11 { \
12 (void) x; \
13 return (a >> LSR) & (1ul << OBIT); \
14 } \
15 \
16 __attribute__((__noipa__)) \
17 uint32_t fun1_lsr_##OBIT##_##LSR##_ni (int x, uint32_t a) \
18 { \
19 return fun1_lsr_##OBIT##_##LSR##_ai (x, a); \
20 } \
21 \
22 void test_fun1_lsr_##OBIT##_##LSR (void) \
23 { \
24 if (fun1_lsr_##OBIT##_##LSR##_ni (0, 1ul << (OBIT + LSR)) \
25 != fun1_lsr_##OBIT##_##LSR##_ai (0, 1ul << (OBIT + LSR))) \
26 __builtin_abort(); \
27 \
28 if (fun1_lsr_##OBIT##_##LSR##_ni (0, 1ul << (OBIT + LSR)) \
29 != fun1_lsr_##OBIT##_##LSR##_ai (0, -1ul)) \
30 __builtin_abort(); \
31 }
32
33
34 #define MK_FUN2(OBIT, LSL) \
35 static __inline__ __attribute__((__always_inline__)) \
36 uint32_t fun2_lsl_##OBIT##_##LSL##_ai (int x, uint32_t a) \
37 { \
38 (void) x; \
39 return (a << LSL) & (1ul << OBIT); \
40 } \
41 \
42 __attribute__((__noipa__)) \
43 uint32_t fun2_lsl_##OBIT##_##LSL##_ni (int x, uint32_t a) \
44 { \
45 return fun2_lsl_##OBIT##_##LSL##_ai (x, a); \
46 } \
47 \
48 void test_fun2_lsl_##OBIT##_##LSL (void) \
49 { \
50 if (fun2_lsl_##OBIT##_##LSL##_ni (0, 1ul << (OBIT - LSL)) \
51 != fun2_lsl_##OBIT##_##LSL##_ai (0, 1ul << (OBIT - LSL))) \
52 __builtin_abort(); \
53 \
54 if (fun2_lsl_##OBIT##_##LSL##_ni (0, 1ul << (OBIT - LSL)) \
55 != fun2_lsl_##OBIT##_##LSL##_ai (0, -1ul)) \
56 __builtin_abort(); \
57 }
58
59
60 MK_FUN1 (13, 15)
61 MK_FUN1 (13, 16)
62 MK_FUN1 (13, 17)
63 MK_FUN1 (13, 12)
64 MK_FUN1 (0, 31)
65 MK_FUN1 (0, 8)
66 MK_FUN1 (0, 0)
67
68 MK_FUN2 (12, 8)
69 MK_FUN2 (13, 8)
70 MK_FUN2 (16, 8)
71 MK_FUN2 (16, 0)
72
73 int main (void)
74 {
75 test_fun1_lsr_13_15 ();
76 test_fun1_lsr_13_16 ();
77 test_fun1_lsr_13_17 ();
78 test_fun1_lsr_13_12 ();
79 test_fun1_lsr_0_31 ();
80 test_fun1_lsr_0_8 ();
81 test_fun1_lsr_0_0 ();
82
83 test_fun2_lsl_12_8 ();
84 test_fun2_lsl_13_8 ();
85 test_fun2_lsl_16_8 ();
86 test_fun2_lsl_16_0 ();
87
88 return 0;
89 }