1 /* { dg-do assemble { target aarch64_asm_sve_ok } } */
2 /* { dg-options "-O2 -ftree-vectorize --save-temps" } */
3 
4 #include <stdint.h>
5 
6 #ifndef INDEX8
7 #define INDEX8 int8_t
8 #define INDEX16 int16_t
9 #define INDEX32 int32_t
10 #define INDEX64 int64_t
11 #endif
12 
13 #define TEST_LOOP(DATA_TYPE, BITS)				\
14   void __attribute__ ((noinline, noclone))			\
15   f_##DATA_TYPE##_##BITS (DATA_TYPE *restrict dest,		\
16 			  DATA_TYPE *restrict src,		\
17 			  INDEX##BITS stride, INDEX##BITS n)	\
18   {								\
19     for (INDEX##BITS i = 0; i < n; ++i)				\
20       dest[i] += src[i * stride];				\
21   }
22 
23 #define TEST_TYPE(T, DATA_TYPE)			\
24   T (DATA_TYPE, 8)				\
25   T (DATA_TYPE, 16)				\
26   T (DATA_TYPE, 32)				\
27   T (DATA_TYPE, 64)
28 
29 #define TEST_ALL(T)				\
30   TEST_TYPE (T, int32_t)			\
31   TEST_TYPE (T, uint32_t)			\
32   TEST_TYPE (T, float)				\
33   TEST_TYPE (T, int64_t)			\
34   TEST_TYPE (T, uint64_t)			\
35   TEST_TYPE (T, double)
36 
37 TEST_ALL (TEST_LOOP)
38 
39 /* { dg-final { scan-assembler-times {\tld1w\tz[0-9]+\.s, p[0-7]/z, \[x[0-9]+, z[0-9]+.s, sxtw 2\]\n} 9 } } */
40 /* { dg-final { scan-assembler-times {\tld1d\tz[0-9]+\.d, p[0-7]/z, \[x[0-9]+, z[0-9]+.d, lsl 3\]\n} 12 } } */
41