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