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]) : 0.0;	\
      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  /* Really we should be able to use MOVPRFX /Z here, but at the moment
      28     we're relying on combine to merge a SEL and an arithmetic operation,
      29     and the SEL doesn't allow zero operands.  */
      30  /* { dg-final { scan-assembler-times {\tmovprfx\tz[0-9]+\.h, p[0-7]/z, z[0-9]+\.h\n} 1 { xfail *-*-* } } } */
      31  /* { dg-final { scan-assembler-times {\tmovprfx\tz[0-9]+\.s, p[0-7]/z, z[0-9]+\.s\n} 1 { xfail *-*-* } } } */
      32  /* { dg-final { scan-assembler-times {\tmovprfx\tz[0-9]+\.d, p[0-7]/z, z[0-9]+\.d\n} 1 { xfail *-*-* } } } */
      33  
      34  /* { dg-final { scan-assembler-not {\tmov\tz[^,]*z} } } */
      35  /* { dg-final { scan-assembler-not {\tsel\t} { xfail *-*-* } } } */