Dead
[official-gcc.git] / gomp-20050608-branch / gcc / testsuite / gcc.dg / vect / vect-reduc-dot-s8.c
blob8e5d48035b304195bf933b9952e27a016b8e0167
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 64
8 #define DOT1 43680
9 #define DOT2 -21856
10 #define DOT3 43680
12 signed char X[N] __attribute__ ((__aligned__(16)));
13 signed char Y[N] __attribute__ ((__aligned__(16)));
15 /* char->short->int dot product.
16 The dot-product pattern should be detected.
17 Vectorizable on vect_sdot_qi targets (targets that support dot-product of
18 signed chars).
20 In the future could also be vectorized as widening-mult + widening-summation,
21 or with type-conversion support.
23 int
24 foo1(int len) {
25 int i;
26 int result = 0;
27 short prod;
29 for (i=0; i<len; i++) {
30 prod = X[i] * Y[i];
31 result += prod;
33 return result;
36 /* char->short->short dot product.
37 The dot-product pattern should be detected.
38 The reduction is currently not vectorized becaus of the signed->unsigned->signed
39 casts, since this patch:
41 2005-12-26 Kazu Hirata <kazu@codesourcery.com>
43 PR tree-optimization/25125
45 When the dot-product is detected, the loop should be vectorized on vect_sdot_qi
46 targets (targets that support dot-product of signed char).
47 This test would currently fail to vectorize on targets that support
48 dot-product of chars when the accumulator is int.
50 In the future could also be vectorized as widening-mult + summation,
51 or with type-conversion support.
53 short
54 foo2(int len) {
55 int i;
56 short result = 0;
58 for (i=0; i<len; i++) {
59 result += (X[i] * Y[i]);
61 return result;
64 /* char->int->int dot product.
65 Not detected as a dot-product pattern.
66 Currently fails to be vectorized due to presence of type conversions. */
67 int
68 foo3(int len) {
69 int i;
70 int result = 0;
72 for (i=0; i<len; i++) {
73 result += (X[i] * Y[i]);
75 return result;
78 int main (void)
80 int i, dot1, dot3;
81 short dot2;
83 check_vect ();
85 for (i=0; i<N; i++) {
86 X[i] = i;
87 Y[i] = 64-i;
90 dot1 = foo1 (N);
91 if (dot1 != DOT1)
92 abort ();
94 dot2 = foo2 (N);
95 if (dot2 != DOT2)
96 abort ();
98 dot3 = foo3 (N);
99 if (dot3 != DOT3)
100 abort ();
102 return 0;
105 /* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 2 "vect" { xfail *-*-* } } } */
106 /* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" } } */
108 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { xfail *-*-* } } } */
109 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_sdot_qi } } } */
111 /* { dg-final { cleanup-tree-dump "vect" } } */