OSDN Git Service

* doc/loop.texi: Document possibility not to perform disambiguation
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vect / wrapv-vect-reduc-dot-s8b.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 DOT -21856
9
10 signed char X[N] __attribute__ ((__aligned__(16)));
11 signed char Y[N] __attribute__ ((__aligned__(16)));
12
13 /* char->short->short dot product.
14    The dot-product pattern should be detected.
15    Should be vectorized on vect_sdot_qi targets (targets that support 
16    dot-product of signed char).  
17    This test currently fails to vectorize on targets that support
18    dot-product of chars into and int accumulator.
19    Can also be vectorized as widening-mult + summation,
20    or with type-conversion support.
21  */
22 short
23 foo(int len) {
24   int i;
25   short result = 0;
26
27   for (i=0; i<len; i++) {
28     result += (X[i] * Y[i]);
29   }
30   return result;
31 }
32
33 int main (void)
34 {
35   int i;
36   short dot;
37
38   check_vect ();
39
40   for (i=0; i<N; i++) {
41     X[i] = i;
42     Y[i] = 64-i;
43   }
44
45   dot = foo (N);
46   if (dot != DOT)
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
55 /* When vectorizer is enhanced to vectorize accumulation into short for targets 
56    that support accumulation into int (e.g. ia64) we'd have:
57 dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_sdot_qi } }
58 */
59 /* In the meantime expect: */
60 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_mult_qi_to_hi } } } */
61
62 /* { dg-final { cleanup-tree-dump "vect" } } */