Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-reduc-dot-s8a.c
blob66ca021a57a69459783cf307261cfbc24e36e549
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 64
8 #define DOT1 43680
10 signed char X[N] __attribute__ ((__aligned__(16)));
11 signed char Y[N] __attribute__ ((__aligned__(16)));
13 /* char->short->int dot product.
14 The dot-product pattern should be detected.
15 Vectorizable on vect_sdot_qi targets (targets that support dot-product of
16 signed chars).
18 In the future could also be vectorized as widening-mult + widening-summation,
19 or with type-conversion support.
21 __attribute__ ((noinline)) int
22 foo1(int len) {
23 int i;
24 int result = 0;
25 short prod;
27 for (i=0; i<len; i++) {
28 prod = X[i] * Y[i];
29 result += prod;
31 return result;
34 int main (void)
36 int i, dot1;
38 check_vect ();
40 for (i=0; i<N; i++) {
41 X[i] = i;
42 Y[i] = 64-i;
45 dot1 = foo1 (N);
46 if (dot1 != DOT1)
47 abort ();
49 return 0;
52 /* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" } } */
53 /* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 1 "vect" } } */
54 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_sdot_qi } } } */
55 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_widen_mult_qi_to_hi && vect_widen_sum_hi_to_si } } } } */
57 /* { dg-final { cleanup-tree-dump "vect" } } */