2009-07-17 Richard Guenther <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-reduc-dot-s8b.c
blobba24af26a034205caf64df1741c2d31ec7b84f65
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 64
8 #define DOT2 -21856
10 signed char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
11 signed char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
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:
18 2005-12-26 Kazu Hirata <kazu@codesourcery.com>
20 PR tree-optimization/25125
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.
29 __attribute__ ((noinline)) short
30 foo2(int len) {
31 int i;
32 short result = 0;
34 for (i=0; i<len; i++) {
35 result += (X[i] * Y[i]);
37 return result;
40 int main (void)
42 int i;
43 short dot2;
45 check_vect ();
47 for (i=0; i<N; i++) {
48 X[i] = i;
49 Y[i] = 64-i;
52 dot2 = foo2 (N);
53 if (dot2 != DOT2)
54 abort ();
56 return 0;
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" } } */
62 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
64 /* { dg-final { cleanup-tree-dump "vect" } } */