(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
vect/
vect-reduc-dot-s8b.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  
      10  #define DOT2 -21856
      11  
      12  signed char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
      13  signed char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
      14  
      15  /* char->short->short dot product.
      16     The dot-product pattern should be detected.
      17  
      18     When the dot-product is detected, the loop should be vectorized on vect_sdot_qi 
      19     targets (targets that support dot-product of signed char).  
      20     This test would currently fail to vectorize on targets that support
      21     dot-product of chars into an int accumulator.
      22     Alternatively, the loop could also be vectorized as widening-mult + summation,
      23     or with type-conversion support.
      24   */
      25  __attribute__ ((noinline)) short
      26  foo2(int len) {
      27    int i;
      28    short result = 0;
      29  
      30    for (i=0; i<len; i++) {
      31      result += (X[i] * Y[i]);
      32    }
      33    return result;
      34  }
      35  
      36  int main (void)
      37  {
      38    int i;
      39    short dot2;
      40  
      41    check_vect ();
      42  
      43    for (i=0; i<N; i++) {
      44      X[i] = i;
      45      Y[i] = 64-i;
      46      __asm__ volatile ("");
      47    }
      48  
      49    dot2 = foo2 (N);
      50    if (dot2 != DOT2)
      51      abort ();
      52  
      53    return 0;
      54  }
      55  
      56  /* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" { xfail *-*-* } } } */
      57  /* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 1 "vect" } } */
      58  
      59  /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_mult_qi_to_hi } } } */
      60