OSDN Git Service

PR tree-optimization/35982
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vect / vect-reduc-dot-s8a.c
1 /* { dg-require-effective-target vect_int } */
2
3 #include <stdarg.h>
4 #include "tree-vect.h"
5
6 #define N 64
7
8 #define DOT1 43680
9
10 signed char X[N] __attribute__ ((__aligned__(16)));
11 signed char Y[N] __attribute__ ((__aligned__(16)));
12
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).
17
18    In the future could also be vectorized as widening-mult + widening-summation,
19    or with type-conversion support.
20  */
21 __attribute__ ((noinline)) int
22 foo1(int len) {
23   int i;
24   int result = 0;
25   short prod;
26
27   for (i=0; i<len; i++) {
28     prod = X[i] * Y[i];
29     result += prod;
30   }
31   return result;
32 }
33
34 int main (void)
35 {
36   int i, dot1;
37
38   check_vect ();
39
40   for (i=0; i<N; i++) {
41     X[i] = i;
42     Y[i] = 64-i;
43   }
44
45   dot1 = foo1 (N);
46   if (dot1 != DOT1)
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 "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 } } } } */
56
57 /* { dg-final { cleanup-tree-dump "vect" } } */