1  /* { dg-do compile } */
       2  /* { dg-options "-O2 -ftree-vectorize -ffast-math -fno-vect-cost-model" } */
       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  /* Widening reductions.  */
      19  REDUC_PTR (int32_t, int8_t)
      20  REDUC_PTR (int32_t, int16_t)
      21  
      22  REDUC_PTR (int64_t, int8_t)
      23  REDUC_PTR (int64_t, int16_t)
      24  REDUC_PTR (int64_t, int32_t)
      25  
      26  REDUC_PTR (float, _Float16)
      27  REDUC_PTR (double, float)
      28  
      29  /* { dg-final { scan-assembler-times {\tuaddv\td[0-9]+, p[0-7], z[0-9]+\.s\n} 2 } } */
      30  /* { dg-final { scan-assembler-times {\tuaddv\td[0-9]+, p[0-7], z[0-9]+\.d\n} 3 } } */
      31  /* { dg-final { scan-assembler-times {\tfaddv\ts[0-9]+, p[0-7], z[0-9]+\.s\n} 1 } } */
      32  /* { dg-final { scan-assembler-times {\tfaddv\td[0-9]+, p[0-7], z[0-9]+\.d\n} 1 } } */