Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-reduc-dot-s16a.c
blobb768c6c8590481e622d474610a72626933bf638c
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 64
7 #define DOT 43680
9 signed short X[N] __attribute__ ((__aligned__(16)));
10 signed short Y[N] __attribute__ ((__aligned__(16)));
12 /* short->int->int dot product.
13 Detected as a dot-product pattern.
14 Vectorized on targets that support dot-product for signed shorts. */
16 __attribute__ ((noinline)) int
17 foo (int len)
19 int i;
20 int result = 0;
22 for (i = 0; i < len; i++)
24 result += (X[i] * Y[i]);
26 return result;
30 int
31 main (void)
33 int i;
34 int dot;
36 check_vect ();
38 for (i = 0; i < N; i++)
40 X[i] = i;
41 Y[i] = N - i;
44 dot = foo (N);
45 if (dot != DOT)
46 abort ();
48 return 0;
51 /* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" } } */
52 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_sdot_hi } } } */
53 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_mult_hi_to_si } } } */
54 /* { dg-final { cleanup-tree-dump "vect" } } */