OSDN Git Service

* gcc.target/i386/sse-17.c: Include sse2-check.h.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vect / 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 DOT2 -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    The reduction is currently not vectorized becaus of the signed->unsigned->signed
16    casts, since this patch:
17
18      2005-12-26  Kazu Hirata  <kazu@codesourcery.com>
19                                                                                                 
20         PR tree-optimization/25125
21
22    When the dot-product is detected, the loop should be vectorized on vect_sdot_qi 
23    targets (targets that support dot-product of signed char).  
24    This test would currently fail to vectorize on targets that support
25    dot-product of chars into an int accumulator.
26    Alternatively, the loop could also be vectorized as widening-mult + summation,
27    or with type-conversion support.
28  */
29 __attribute__ ((noinline)) short
30 foo2(int len) {
31   int i;
32   short result = 0;
33
34   for (i=0; i<len; i++) {
35     result += (X[i] * Y[i]);
36   }
37   return result;
38 }
39
40 int main (void)
41 {
42   int i;
43   short dot2;
44
45   check_vect ();
46
47   for (i=0; i<N; i++) {
48     X[i] = i;
49     Y[i] = 64-i;
50   }
51
52   dot2 = foo2 (N);
53   if (dot2 != DOT2)
54     abort ();
55
56   return 0;
57 }
58
59 /* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" { xfail *-*-* } } } */
60 /* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 1 "vect" } } */
61
62 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
63
64 /* { dg-final { cleanup-tree-dump "vect" } } */