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 ? y[i] + (TYPE) CONST : y[i];	\
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   T (TYPE, PRED_TYPE, minus_half, -0.5) \
22   T (TYPE, PRED_TYPE, minus_one, -1.0) \
23   T (TYPE, PRED_TYPE, minus_two, -2.0)
24 
25 #define TEST_ALL(T) \
26   TEST_TYPE (T, _Float16, int16_t) \
27   TEST_TYPE (T, float, int32_t) \
28   TEST_TYPE (T, double, int64_t)
29 
30 TEST_ALL (DEF_LOOP)
31 
32 /* { dg-final { scan-assembler-times {\tfadd\tz[0-9]+\.h, p[0-7]/m, z[0-9]+\.h, #0\.5\n} 1 } } */
33 /* { dg-final { scan-assembler-times {\tfadd\tz[0-9]+\.s, p[0-7]/m, z[0-9]+\.s, #0\.5\n} 1 } } */
34 /* { dg-final { scan-assembler-times {\tfadd\tz[0-9]+\.d, p[0-7]/m, z[0-9]+\.d, #0\.5\n} 1 } } */
35 
36 /* { dg-final { scan-assembler-times {\tfadd\tz[0-9]+\.h, p[0-7]/m, z[0-9]+\.h, #1\.0\n} 1 } } */
37 /* { dg-final { scan-assembler-times {\tfadd\tz[0-9]+\.s, p[0-7]/m, z[0-9]+\.s, #1\.0\n} 1 } } */
38 /* { dg-final { scan-assembler-times {\tfadd\tz[0-9]+\.d, p[0-7]/m, z[0-9]+\.d, #1\.0\n} 1 } } */
39 
40 /* { dg-final { scan-assembler-times {\tfsub\tz[0-9]+\.h, p[0-7]/m, z[0-9]+\.h, #0\.5\n} 1 } } */
41 /* { dg-final { scan-assembler-times {\tfsub\tz[0-9]+\.s, p[0-7]/m, z[0-9]+\.s, #0\.5\n} 1 } } */
42 /* { dg-final { scan-assembler-times {\tfsub\tz[0-9]+\.d, p[0-7]/m, z[0-9]+\.d, #0\.5\n} 1 } } */
43 
44 /* { dg-final { scan-assembler-times {\tfsub\tz[0-9]+\.h, p[0-7]/m, z[0-9]+\.h, #1\.0\n} 1 } } */
45 /* { dg-final { scan-assembler-times {\tfsub\tz[0-9]+\.s, p[0-7]/m, z[0-9]+\.s, #1\.0\n} 1 } } */
46 /* { dg-final { scan-assembler-times {\tfsub\tz[0-9]+\.d, p[0-7]/m, z[0-9]+\.d, #1\.0\n} 1 } } */
47 
48 /* { dg-final { scan-assembler-times {\tfmov\tz[0-9]+\.h, #2\.0} 1 } } */
49 /* { dg-final { scan-assembler-times {\tfmov\tz[0-9]+\.s, #2\.0} 1 } } */
50 /* { dg-final { scan-assembler-times {\tfmov\tz[0-9]+\.d, #2\.0} 1 } } */
51 
52 /* { dg-final { scan-assembler-times {\tfmov\tz[0-9]+\.h, #-2\.0} 1 } } */
53 /* { dg-final { scan-assembler-times {\tfmov\tz[0-9]+\.s, #-2\.0} 1 } } */
54 /* { dg-final { scan-assembler-times {\tfmov\tz[0-9]+\.d, #-2\.0} 1 } } */
55 
56 /* { dg-final { scan-assembler-times {\tfadd\tz[0-9]+\.h, p[0-7]/m, z[0-9]+\.h, z[0-9]+\.h\n} 2 } } */
57 /* { dg-final { scan-assembler-times {\tfadd\tz[0-9]+\.s, p[0-7]/m, z[0-9]+\.s, z[0-9]+\.s\n} 2 } } */
58 /* { dg-final { scan-assembler-times {\tfadd\tz[0-9]+\.d, p[0-7]/m, z[0-9]+\.d, z[0-9]+\.d\n} 2 } } */
59 
60 /* { dg-final { scan-assembler-not {\tmov\tz} } } */
61 /* { dg-final { scan-assembler-not {\tmovprfx\t} } } */
62 /* { dg-final { scan-assembler-not {\tsel\t} } } */
63