OSDN Git Service

38753f725d8182380fc9fbda76cb0333a8934b15
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vect / vect-reduc-dot-u16a.c
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__(16)));
12 unsigned short Y[N] __attribute__ ((__aligned__(16)));
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 unsigned int
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
30 int main (void)
31 {
32   unsigned int dot1;
33   int 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 /* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" { xfail *-*-* } } } */
50 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_short_mult && vect_widen_sum_hi_to_si } } } } */ 
51
52 /* { dg-final { cleanup-tree-dump "vect" } } */