(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
vect/
vect-reduc-dot-s16a.c
       1  /* Disabling epilogues until we find a better way to deal with scans.  */
       2  /* { dg-additional-options "--param vect-epilogues-nomask=0" } */
       3  /* { dg-require-effective-target vect_int } */
       4  
       5  #include <stdarg.h>
       6  #include "tree-vect.h"
       7  
       8  #define N 64
       9  #define DOT 43680
      10  
      11  signed short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
      12  signed short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
      13  
      14  /* short->int->int dot product.
      15     Detected as a dot-product pattern.
      16     Vectorized on targets that support dot-product for signed shorts.  */
      17  
      18  __attribute__ ((noinline)) int
      19  foo (int len)
      20  {
      21    int i;
      22    int result = 0;
      23  
      24    for (i = 0; i < len; i++)
      25      {
      26        result += (X[i] * Y[i]);
      27      }
      28    return result;
      29  }
      30  
      31  
      32  int
      33  main (void)
      34  {
      35    int i;
      36    int dot;
      37  
      38    check_vect ();
      39  
      40    for (i = 0; i < N; i++)
      41      {
      42        X[i] = i;
      43        Y[i] = N - i;
      44        __asm__ volatile ("");
      45      }
      46  
      47    dot = foo (N);
      48    if (dot != DOT)
      49      abort ();
      50  
      51    return 0;
      52  }
      53  
      54  /* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" } } */
      55  /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_sdot_hi } } } */
      56  /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_mult_hi_to_si } } } */
      57