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