(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
aarch64/
sve/
dot_1.c
       1  /* { dg-do compile } */
       2  /* { dg-options "-O2 -ftree-vectorize" } */
       3  
       4  #include <stdint.h>
       5  
       6  #define DEF_DOT(TYPE1, TYPE2)						\
       7  TYPE1 __attribute__ ((noinline, noclone))				\
       8  dot_##TYPE1##_##TYPE2 (TYPE2 *restrict x, TYPE2 *restrict y, int n)	\
       9  {									\
      10    TYPE1 sum = 0;							\
      11    for (int i = 0; i < n; i++)						\
      12      {									\
      13        sum += x[i] * y[i];						\
      14      }									\
      15    return sum;								\
      16  }
      17  
      18  DEF_DOT(uint32_t, uint8_t)
      19  DEF_DOT(int32_t, int8_t)
      20  DEF_DOT(int64_t, int16_t)
      21  
      22  /* The uint16_t->uint64_t dot product requires a casting to satisfy the C
      23     language rules.  */
      24  uint64_t __attribute__ ((noinline, noclone))
      25  dot_uint64_t_uint16_t (uint16_t *restrict x, uint16_t *restrict y, int n)
      26  {
      27    uint64_t sum = 0;
      28    for (int i = 0; i < n; i++)
      29      {
      30        sum += (unsigned int)x[i] * y[i];
      31      }
      32    return sum;
      33  }
      34  
      35  /* { dg-final { scan-assembler-times {\tudot\tz[0-9]+\.s, z[0-9]+\.b, z[0-9]+\.b\n} 1 } } */
      36  /* { dg-final { scan-assembler-times {\tsdot\tz[0-9]+\.s, z[0-9]+\.b, z[0-9]+\.b\n} 1 } } */
      37  /* { dg-final { scan-assembler-times {\tudot\tz[0-9]+\.d, z[0-9]+\.h, z[0-9]+\.h\n} 1 } } */
      38  /* { dg-final { scan-assembler-times {\tsdot\tz[0-9]+\.d, z[0-9]+\.h, z[0-9]+\.h\n} 1 } } */
      39  /* { dg-final { scan-assembler-times {\twhilelo\t} 8 } } */