| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-additional-options { -fno-split-wide-types } } */ |
| 3 |
|
| 4 |
typedef __UINT16_TYPE__ uint16_t; |
| 5 |
|
| 6 |
/* Testing inlined and completely folded versions of functions |
| 7 |
against their non-inlined, non-folded counnterparts. */ |
| 8 |
|
| 9 |
#define MK_FUN1(OBIT, LSR) \ |
| 10 |
static __inline__ __attribute__((__always_inline__)) \ |
| 11 |
uint16_t fun1_lsr_##OBIT##_##LSR##_ai (int x, uint16_t a) \ |
| 12 |
{ \ |
| 13 |
(void) x; \ |
| 14 |
return (a >> LSR) & (1u << OBIT); \ |
| 15 |
} \ |
| 16 |
\ |
| 17 |
__attribute__((__noipa__)) \ |
| 18 |
uint16_t fun1_lsr_##OBIT##_##LSR##_ni (int x, uint16_t a) \ |
| 19 |
{ \ |
| 20 |
return fun1_lsr_##OBIT##_##LSR##_ai (x, a); \ |
| 21 |
} \ |
| 22 |
\ |
| 23 |
void test_fun1_lsr_##OBIT##_##LSR (void) \ |
| 24 |
{ \ |
| 25 |
if (fun1_lsr_##OBIT##_##LSR##_ni (0, 1u << (OBIT + LSR)) \ |
| 26 |
!= fun1_lsr_##OBIT##_##LSR##_ai (0, 1u << (OBIT + LSR))) \ |
| 27 |
__builtin_abort(); \ |
| 28 |
\ |
| 29 |
if (fun1_lsr_##OBIT##_##LSR##_ni (0, 1u << (OBIT + LSR)) \ |
| 30 |
!= fun1_lsr_##OBIT##_##LSR##_ai (0, -1u)) \ |
| 31 |
__builtin_abort(); \ |
| 32 |
} |
| 33 |
|
| 34 |
#define MK_FUN3(OBIT, LSR) \ |
| 35 |
static __inline__ __attribute__((__always_inline__)) \ |
| 36 |
uint16_t fun3_lsr_##OBIT##_##LSR##_ai (uint16_t a) \ |
| 37 |
{ \ |
| 38 |
return (a >> LSR) & (1u << OBIT); \ |
| 39 |
} \ |
| 40 |
\ |
| 41 |
__attribute__((__noipa__)) \ |
| 42 |
uint16_t fun3_lsr_##OBIT##_##LSR##_ni (uint16_t a) \ |
| 43 |
{ \ |
| 44 |
return fun3_lsr_##OBIT##_##LSR##_ai (a); \ |
| 45 |
} \ |
| 46 |
\ |
| 47 |
void test_fun3_lsr_##OBIT##_##LSR (void) \ |
| 48 |
{ \ |
| 49 |
if (fun3_lsr_##OBIT##_##LSR##_ni (1u << (OBIT + LSR)) \ |
| 50 |
!= fun3_lsr_##OBIT##_##LSR##_ai (1u << (OBIT + LSR))) \ |
| 51 |
__builtin_abort(); \ |
| 52 |
\ |
| 53 |
if (fun3_lsr_##OBIT##_##LSR##_ni (1u << (OBIT + LSR)) \ |
| 54 |
!= fun3_lsr_##OBIT##_##LSR##_ai (-1u)) \ |
| 55 |
__builtin_abort(); \ |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
#define MK_FUN2(OBIT, LSL) \ |
| 60 |
static __inline__ __attribute__((__always_inline__)) \ |
| 61 |
uint16_t fun2_lsl_##OBIT##_##LSL##_ai (uint16_t a) \ |
| 62 |
{ \ |
| 63 |
return (a << LSL) & (1u << OBIT); \ |
| 64 |
} \ |
| 65 |
\ |
| 66 |
__attribute__((__noipa__)) \ |
| 67 |
uint16_t fun2_lsl_##OBIT##_##LSL##_ni (uint16_t a) \ |
| 68 |
{ \ |
| 69 |
return fun2_lsl_##OBIT##_##LSL##_ai (a); \ |
| 70 |
} \ |
| 71 |
\ |
| 72 |
void test_fun2_lsl_##OBIT##_##LSL (void) \ |
| 73 |
{ \ |
| 74 |
if (fun2_lsl_##OBIT##_##LSL##_ni (1u << (OBIT - LSL)) \ |
| 75 |
!= fun2_lsl_##OBIT##_##LSL##_ai (1u << (OBIT - LSL))) \ |
| 76 |
__builtin_abort(); \ |
| 77 |
\ |
| 78 |
if (fun2_lsl_##OBIT##_##LSL##_ni (1u << (OBIT - LSL)) \ |
| 79 |
!= fun2_lsl_##OBIT##_##LSL##_ai (-1u)) \ |
| 80 |
__builtin_abort(); \ |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
MK_FUN1 (10, 4) |
| 85 |
MK_FUN1 (6, 1) |
| 86 |
MK_FUN1 (1, 5) |
| 87 |
MK_FUN1 (0, 8) |
| 88 |
MK_FUN1 (0, 4) |
| 89 |
MK_FUN1 (0, 1) |
| 90 |
MK_FUN1 (0, 0) |
| 91 |
|
| 92 |
MK_FUN3 (10, 4) |
| 93 |
MK_FUN3 (6, 1) |
| 94 |
MK_FUN3 (1, 5) |
| 95 |
MK_FUN3 (0, 8) |
| 96 |
MK_FUN3 (0, 4) |
| 97 |
MK_FUN3 (0, 1) |
| 98 |
MK_FUN3 (0, 0) |
| 99 |
|
| 100 |
MK_FUN2 (12, 8) |
| 101 |
MK_FUN2 (15, 15) |
| 102 |
MK_FUN2 (14, 12) |
| 103 |
MK_FUN2 (8, 8) |
| 104 |
MK_FUN2 (7, 4) |
| 105 |
MK_FUN2 (5, 4) |
| 106 |
MK_FUN2 (5, 1) |
| 107 |
MK_FUN2 (4, 0) |
| 108 |
MK_FUN2 (1, 0) |
| 109 |
MK_FUN2 (0, 0) |
| 110 |
|
| 111 |
int main (void) |
| 112 |
{ |
| 113 |
test_fun1_lsr_10_4 (); |
| 114 |
test_fun1_lsr_6_1 (); |
| 115 |
test_fun1_lsr_1_5 (); |
| 116 |
test_fun1_lsr_0_8 (); |
| 117 |
test_fun1_lsr_0_4 (); |
| 118 |
test_fun1_lsr_0_1 (); |
| 119 |
test_fun1_lsr_0_0 (); |
| 120 |
|
| 121 |
test_fun3_lsr_10_4 (); |
| 122 |
test_fun3_lsr_6_1 (); |
| 123 |
test_fun3_lsr_1_5 (); |
| 124 |
test_fun3_lsr_0_8 (); |
| 125 |
test_fun3_lsr_0_4 (); |
| 126 |
test_fun3_lsr_0_1 (); |
| 127 |
test_fun3_lsr_0_0 (); |
| 128 |
|
| 129 |
test_fun2_lsl_12_8 (); |
| 130 |
test_fun2_lsl_15_15 (); |
| 131 |
test_fun2_lsl_14_12 (); |
| 132 |
test_fun2_lsl_8_8 (); |
| 133 |
test_fun2_lsl_7_4 (); |
| 134 |
test_fun2_lsl_5_4 (); |
| 135 |
test_fun2_lsl_5_1 (); |
| 136 |
test_fun2_lsl_4_0 (); |
| 137 |
test_fun2_lsl_1_0 (); |
| 138 |
test_fun2_lsl_0_0 (); |
| 139 |
|
| 140 |
return 0; |
| 141 |
} |