1 /* { dg-do compile } */
2 /* { dg-options "-O2 -ftree-vectorize" } */
3 
4 #include <stdint.h>
5 
6 #define DEF_LOOP(TYPE, PRED_TYPE, NAME, CONST)		\
7   void __attribute__ ((noipa))				\
8   test_##TYPE##_##NAME (TYPE *__restrict x,		\
9 			TYPE *__restrict y,		\
10 			PRED_TYPE *__restrict pred,	\
11 			int n)				\
12   {							\
13     for (int i = 0; i < n; ++i)				\
14       x[i] = pred[i] != 1 ? (TYPE) CONST - y[i] : 4;	\
15   }
16 
17 #define TEST_TYPE(T, TYPE, PRED_TYPE) \
18   T (TYPE, PRED_TYPE, half, 0.5) \
19   T (TYPE, PRED_TYPE, one, 1.0) \
20   T (TYPE, PRED_TYPE, two, 2.0)
21 
22 #define TEST_ALL(T) \
23   TEST_TYPE (T, _Float16, int16_t) \
24   TEST_TYPE (T, float, int32_t) \
25   TEST_TYPE (T, double, int64_t)
26 
27 TEST_ALL (DEF_LOOP)
28 
29 /* { dg-final { scan-assembler-times {\tfsubr\tz[0-9]+\.h, p[0-7]/m, z[0-9]+\.h, #0\.5\n} 1 } } */
30 /* { dg-final { scan-assembler-times {\tfsubr\tz[0-9]+\.s, p[0-7]/m, z[0-9]+\.s, #0\.5\n} 1 } } */
31 /* { dg-final { scan-assembler-times {\tfsubr\tz[0-9]+\.d, p[0-7]/m, z[0-9]+\.d, #0\.5\n} 1 } } */
32 
33 /* { dg-final { scan-assembler-times {\tfsubr\tz[0-9]+\.h, p[0-7]/m, z[0-9]+\.h, #1\.0\n} 1 } } */
34 /* { dg-final { scan-assembler-times {\tfsubr\tz[0-9]+\.s, p[0-7]/m, z[0-9]+\.s, #1\.0\n} 1 } } */
35 /* { dg-final { scan-assembler-times {\tfsubr\tz[0-9]+\.d, p[0-7]/m, z[0-9]+\.d, #1\.0\n} 1 } } */
36 
37 /* { dg-final { scan-assembler-times {\tfmov\tz[0-9]+\.h, #2\.0} 1 } } */
38 /* { dg-final { scan-assembler-times {\tfmov\tz[0-9]+\.s, #2\.0} 1 } } */
39 /* { dg-final { scan-assembler-times {\tfmov\tz[0-9]+\.d, #2\.0} 1 } } */
40 
41 /* { dg-final { scan-assembler-times {\tfsub\tz[0-9]+\.h, p[0-7]/m, z[0-9]+\.h, z[0-9]+\.h\n} 1 } } */
42 /* { dg-final { scan-assembler-times {\tfsub\tz[0-9]+\.s, p[0-7]/m, z[0-9]+\.s, z[0-9]+\.s\n} 1 } } */
43 /* { dg-final { scan-assembler-times {\tfsub\tz[0-9]+\.d, p[0-7]/m, z[0-9]+\.d, z[0-9]+\.d\n} 1 } } */
44 
45 /* { dg-final { scan-assembler-times {\tsel\tz[0-9]+\.h, p[0-7], z[0-9]+\.h, z[0-9]+\.h\n} 3 } } */
46 /* { dg-final { scan-assembler-times {\tsel\tz[0-9]+\.h, p[0-7], z[0-9]+\.h, z[0-9]+\.h\n} 3 } } */
47 /* { dg-final { scan-assembler-times {\tsel\tz[0-9]+\.h, p[0-7], z[0-9]+\.h, z[0-9]+\.h\n} 3 } } */
48 
49 /* { dg-final { scan-assembler-not {\tmovprfx\t} } } */
50 /* { dg-final { scan-assembler-not {\tmov\tz} } } */
51