1 /* { dg-require-effective-target vect_int } */
2 
3 #include <stdarg.h>
4 #include "tree-vect.h"
5 
6 #define N 64
7 
8 #define DOT1 43680
9 #define DOT2 43680
10 
11 unsigned short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
12 unsigned short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
13 
14 /* short->short->int dot product.
15    Not detected as a dot-product pattern.
16    Requires support for non-widneing multiplication and widening-summation.  */
17 __attribute__ ((noinline)) unsigned int
foo1(int len)18 foo1(int len) {
19   int i;
20   unsigned int result = 0;
21   unsigned short prod;
22 
23   for (i=0; i<len; i++) {
24     prod = X[i] * Y[i];
25     result += prod;
26   }
27   return result;
28 }
29 
main(void)30 int main (void)
31 {
32   unsigned int dot1;
33   unsigned short i;
34 
35   check_vect ();
36 
37   for (i=0; i<N; i++) {
38     X[i] = i;
39     Y[i] = 64-i;
40   }
41 
42   dot1 = foo1 (N);
43   if (dot1 != DOT1)
44     abort ();
45 
46   return 0;
47 }
48 
49 /* The initialization loop in main also gets vectorized.  */
50 /* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" { xfail *-*-* } } } */
51 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target { vect_short_mult && vect_widen_sum_hi_to_si } } } } */
52