1 /* { dg-do compile } */ 2 /* { dg-options "-O2 -ftree-vectorize -fno-trapping-math" } */ 3 4 #include <stdint.h> 5 6 #define DEF_LOOP(TYPE, ABS) \ 7 void __attribute__ ((noinline, noclone)) \ 8 test_##TYPE (TYPE *__restrict r, TYPE *__restrict a, \ 9 TYPE *__restrict b, TYPE *__restrict c, \ 10 int n) \ 11 { \ 12 for (int i = 0; i < n; ++i) \ 13 r[i] = a[i] < 20 ? ABS (b[i] - c[i]) : a[i]; \ 14 } 15 16 #define TEST_ALL(T) \ 17 T (_Float16, __builtin_fabsf16) \ 18 T (float, __builtin_fabsf) \ 19 T (double, __builtin_fabs) 20 21 TEST_ALL (DEF_LOOP) 22 23 /* { dg-final { scan-assembler-times {\tfabd\tz[0-9]+\.h, p[0-7]/m,} 1 } } */ 24 /* { dg-final { scan-assembler-times {\tfabd\tz[0-9]+\.s, p[0-7]/m,} 1 } } */ 25 /* { dg-final { scan-assembler-times {\tfabd\tz[0-9]+\.d, p[0-7]/m,} 1 } } */ 26 27 /* { dg-final { scan-assembler-times {\tmovprfx\tz[0-9]+\.h, p[0-7]/m, z[0-9]+\.h\n} 1 } } */ 28 /* { dg-final { scan-assembler-times {\tmovprfx\tz[0-9]+\.s, p[0-7]/m, z[0-9]+\.s\n} 1 } } */ 29 /* { dg-final { scan-assembler-times {\tmovprfx\tz[0-9]+\.d, p[0-7]/m, z[0-9]+\.d\n} 1 } } */ 30 31 /* { dg-final { scan-assembler-not {\tmov\tz[^,]*z} } } */ 32 /* { dg-final { scan-assembler-not {\tsel\t} } } */ 33