1  /* { dg-do compile } */
       2  /* { dg-require-effective-target arm_v8_1m_mve_ok } */
       3  /* { dg-add-options arm_v8_1m_mve } */
       4  /* { dg-additional-options "-O3" } */
       5  
       6  #include <stdint.h>
       7  
       8  /* We force a cast to int64_t to enable the vectorizer when dealing with 32-bit
       9     inputs.  */
      10  #define FUNC(SIGN, TYPE, BITS, OP, NAME)				\
      11    void test_ ## NAME ##_ ## SIGN ## BITS (TYPE##BITS##_t * __restrict__ dest, \
      12  					  TYPE##BITS##_t *a, TYPE##BITS##_t *b) { \
      13      int i;								\
      14      for (i=0; i < (128 / BITS); i++) {					\
      15        dest[i] = ((int64_t)a[i] OP b[i] + 1) >> 1;			\
      16      }									\
      17  }
      18  
      19  FUNC(s, int, 32, +, vrhadd)
      20  FUNC(u, uint, 32, +, vrhadd)
      21  FUNC(s, int, 16, +, vrhadd)
      22  FUNC(u, uint, 16, +, vrhadd)
      23  FUNC(s, int, 8, +, vrhadd)
      24  FUNC(u, uint, 8, +, vrhadd)
      25  
      26  /* { dg-final { scan-assembler-times {vrhadd\.s32\tq[0-9]+, q[0-9]+, q[0-9]+} 1 } } */
      27  /* { dg-final { scan-assembler-times {vrhadd\.u32\tq[0-9]+, q[0-9]+, q[0-9]+} 1 } } */
      28  /* { dg-final { scan-assembler-times {vrhadd\.s16\tq[0-9]+, q[0-9]+, q[0-9]+} 1 } } */
      29  /* { dg-final { scan-assembler-times {vrhadd\.u16\tq[0-9]+, q[0-9]+, q[0-9]+} 1 } } */
      30  /* { dg-final { scan-assembler-times {vrhadd\.s8\tq[0-9]+, q[0-9]+, q[0-9]+} 1 } } */
      31  /* { dg-final { scan-assembler-times {vrhadd\.u8\tq[0-9]+, q[0-9]+, q[0-9]+} 1 } } */