1 /* { dg-do compile } */
2 /* { dg-options "-O2 -ftree-vectorize" } */
3 
4 #include <stdint.h>
5 
6 #define VEC_PERM(TYPE1, TYPE2)					\
7 void __attribute__ ((noinline, noclone))			\
8 vec_slp_##TYPE1##_##TYPE2 (TYPE1 *restrict a,			\
9 			   TYPE2 *restrict b, int n)		\
10 {								\
11   for (int i = 0; i < n; ++i)					\
12     {								\
13       a[i * 2] += 1;						\
14       a[i * 2 + 1] += 2;					\
15       b[i * 2] += 3;						\
16       b[i * 2 + 1] += 4;					\
17     }								\
18 }
19 
20 #define TEST_ALL(T)				\
21   T (int8_t, uint16_t)				\
22   T (uint8_t, int16_t)				\
23   T (int16_t, uint32_t)				\
24   T (uint16_t, int32_t)				\
25   T (int32_t, double)				\
26   T (uint32_t, int64_t)				\
27   T (float, uint64_t)
28 
29 TEST_ALL (VEC_PERM)
30 
31 /* The loop should be fully-masked.  The load XFAILs for fixed-length
32    SVE account for extra loads from the constant pool.  */
33 /* { dg-final { scan-assembler-times {\tld1b\t} 2 { xfail { aarch64_sve && { ! vect_variable_length } } } } }*/
34 /* { dg-final { scan-assembler-times {\tst1b\t} 2 } } */
35 /* { dg-final { scan-assembler-times {\tld1h\t} 6 { xfail { aarch64_sve && { ! vect_variable_length } } } } } */
36 /* { dg-final { scan-assembler-times {\tst1h\t} 6 } } */
37 /* { dg-final { scan-assembler-times {\tld1w\t} 7 { xfail { aarch64_sve && { ! vect_variable_length } } } } } */
38 /* { dg-final { scan-assembler-times {\tst1w\t} 7 } } */
39 /* { dg-final { scan-assembler-times {\tld1d\t} 6 { xfail { aarch64_sve && { ! vect_variable_length } } } } } */
40 /* { dg-final { scan-assembler-times {\tst1d\t} 6 } } */
41 /* { dg-final { scan-assembler-not {\tldr} } } */
42 /* { dg-final { scan-assembler-not {\tstr} } } */
43 
44 /* We should use WHILEs for the accesses to "a" and unpacks for the accesses
45    to "b".  */
46 /* { dg-final { scan-assembler-times {\twhilelo\tp[0-7]\.b} 4 } } */
47 /* { dg-final { scan-assembler-times {\twhilelo\tp[0-7]\.h} 4 } } */
48 /* { dg-final { scan-assembler-times {\twhilelo\tp[0-7]\.s} 6 } } */
49 /* { dg-final { scan-assembler-not {\twhilelo\tp[0-7]\.d} } } */
50 /* { dg-final { scan-assembler-times {\tpunpklo\tp[0-7]\.h} 7 } } */
51 /* { dg-final { scan-assembler-times {\tpunpkhi\tp[0-7]\.h} 7 } } */
52 
53 /* { dg-final { scan-assembler-not {\tuqdec} } } */
54