Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-reduc-dot-s16b.c
blob8c636a5f703dbc638fcd97c3326275aea3782827
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 64
8 #define DOT 43680
10 signed short X[N] __attribute__ ((__aligned__(16)));
11 signed short Y[N] __attribute__ ((__aligned__(16)));
13 /* short->short->int dot product. Should be vectorized on architectures
14 supporting vectorized multiplication of two short args with short result,
15 e.g "mulv4hi3" and widenning sum */
16 __attribute__ ((noinline)) int
17 foo (int len)
19 int i;
20 int result = 0;
21 short prod;
23 for (i = 0; i < len; i++)
25 prod = X[i] * Y[i];
26 result += prod;
28 return result;
31 int
32 main (void)
34 int i, dot;
36 check_vect ();
38 for (i = 0; i < N; i++)
40 X[i] = i;
41 Y[i] = 64 - i;
44 dot = foo (N);
45 if (dot != DOT)
46 abort ();
48 return 0;
51 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_short_mult && vect_widen_sum_hi_to_si } } } } */
52 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_short_mult } } } } */
53 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_widen_sum_hi_to_si } } } } */
55 /* { dg-final { cleanup-tree-dump "vect" } } */