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