Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gcc.dg / vect / vect-reduc-dot-s8a.c
blob96c2950c08806cb9a9f2d5f1bfd78289057a5bba
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__(__BIGGEST_ALIGNMENT__)));
11 signed char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
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;
43 __asm__ volatile ("");
46 dot1 = foo1 (N);
47 if (dot1 != DOT1)
48 abort ();
50 return 0;
53 /* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" } } */
54 /* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 1 "vect" } } */
55 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_sdot_qi } } } */
56 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_widen_mult_qi_to_hi && vect_widen_sum_hi_to_si } } } } */
58 /* { dg-final { cleanup-tree-dump "vect" } } */