1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/* { dg-do compile } */
/* { dg-options "-O2 -ftree-vectorize -ffast-math -fno-inline -march=armv8-a+sve" } */
#include <stdint.h>
#define NUM_ELEMS(TYPE) (32 / sizeof (TYPE))
#define REDUC_PTR(DSTTYPE, SRCTYPE) \
void reduc_ptr_##DSTTYPE##_##SRCTYPE (DSTTYPE *restrict sum, \
SRCTYPE *restrict array, \
int count) \
{ \
*sum = 0; \
for (int i = 0; i < count; ++i) \
*sum += array[i]; \
}
REDUC_PTR (int8_t, int8_t)
REDUC_PTR (int16_t, int16_t)
REDUC_PTR (int32_t, int32_t)
REDUC_PTR (int64_t, int64_t)
REDUC_PTR (float, float)
REDUC_PTR (double, double)
/* Widening reductions. */
REDUC_PTR (int32_t, int8_t)
REDUC_PTR (int32_t, int16_t)
REDUC_PTR (int64_t, int8_t)
REDUC_PTR (int64_t, int16_t)
REDUC_PTR (int64_t, int32_t)
REDUC_PTR (double, float)
/* Float<>Int conversions */
REDUC_PTR (float, int32_t)
REDUC_PTR (double, int64_t)
REDUC_PTR (int32_t, float)
REDUC_PTR (int64_t, double)
/* { dg-final { scan-assembler-times {\tuaddv\td[0-9]+, p[0-7], z[0-9]+\.s\n} 3 } } */
/* { dg-final { scan-assembler-times {\tuaddv\td[0-9]+, p[0-7], z[0-9]+\.d\n} 4 } } */
/* { dg-final { scan-assembler-times {\tfaddv\ts[0-9]+, p[0-7], z[0-9]+\.s\n} 2 } } */
/* { dg-final { scan-assembler-times {\tfaddv\td[0-9]+, p[0-7], z[0-9]+\.d\n} 3 } } */
|