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