1  /* { dg-do compile } */
       2  /* { dg-options "-O2 -ftree-vectorize -ffast-math" } */
       3  
       4  #include <stdint.h>
       5  
       6  #define NUM_ELEMS(TYPE) (32 / sizeof (TYPE))
       7  
       8  #define REDUC_PTR(DSTTYPE, SRCTYPE)				\
       9  void reduc_ptr_##DSTTYPE##_##SRCTYPE (DSTTYPE *restrict sum,	\
      10  				      SRCTYPE *restrict array,	\
      11  				      int count)		\
      12  {								\
      13    *sum = 0;							\
      14    for (int i = 0; i < count; ++i)				\
      15      *sum += array[i];						\
      16  }
      17  
      18  REDUC_PTR (int8_t, int8_t)
      19  REDUC_PTR (int16_t, int16_t)
      20  REDUC_PTR (int32_t, int32_t)
      21  REDUC_PTR (int64_t, int64_t)
      22  
      23  REDUC_PTR (_Float16, _Float16)
      24  REDUC_PTR (float, float)
      25  REDUC_PTR (double, double)
      26  
      27  /* Float<>Int conversions */
      28  REDUC_PTR (_Float16, int16_t)
      29  REDUC_PTR (float, int32_t)
      30  REDUC_PTR (double, int64_t)
      31  
      32  REDUC_PTR (int16_t, _Float16)
      33  REDUC_PTR (int32_t, float)
      34  REDUC_PTR (int64_t, double)
      35  
      36  /* { dg-final { scan-assembler-times {\tuaddv\td[0-9]+, p[0-7], z[0-9]+\.b\n} 1 } } */
      37  /* { dg-final { scan-assembler-times {\tuaddv\td[0-9]+, p[0-7], z[0-9]+\.h\n} 2 { xfail *-*-* } } } */
      38  /* { dg-final { scan-assembler-times {\tuaddv\td[0-9]+, p[0-7], z[0-9]+\.s\n} 2 { xfail *-*-* } } } */
      39  /* { dg-final { scan-assembler-times {\tuaddv\td[0-9]+, p[0-7], z[0-9]+\.d\n} 2 { xfail *-*-* } } } */
      40  /* We don't yet vectorize the int<-float cases.  */
      41  /* { dg-final { scan-assembler-times {\tuaddv\td[0-9]+, p[0-7], z[0-9]+\.h\n} 1 } } */
      42  /* { dg-final { scan-assembler-times {\tuaddv\td[0-9]+, p[0-7], z[0-9]+\.s\n} 1 } } */
      43  /* { dg-final { scan-assembler-times {\tuaddv\td[0-9]+, p[0-7], z[0-9]+\.d\n} 1 } } */
      44  /* { dg-final { scan-assembler-times {\tfaddv\th[0-9]+, p[0-7], z[0-9]+\.h\n} 2 } } */
      45  /* { dg-final { scan-assembler-times {\tfaddv\ts[0-9]+, p[0-7], z[0-9]+\.s\n} 2 } } */
      46  /* { dg-final { scan-assembler-times {\tfaddv\td[0-9]+, p[0-7], z[0-9]+\.d\n} 2 } } */