Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-reduc-dot-u8b.c
blobbfe3769008b40cee7c7785b175a173ac3b556782
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 64
8 #define DOT 43680
10 unsigned char X[N] __attribute__ ((__aligned__(16)));
11 unsigned char Y[N] __attribute__ ((__aligned__(16)));
13 /* char->short->short dot product.
14 Detected as a dot-product pattern.
15 Should be vectorized on targets that support dot-product for unsigned chars,
16 but currently this test cannot be vectorized as a dot-product on targets
17 that support char->short->int dot-product.
18 Alternatively, this test can be vectorized using vect_widen_mult_qi (or
19 vect_unpack and non-widening multplication: vect_unpack && vect_short_mult).
21 __attribute__ ((noinline)) unsigned short
22 foo (int len) {
23 int i;
24 unsigned short result = 0;
26 for (i=0; i<len; i++) {
27 result += (unsigned short)(X[i] * Y[i]);
29 return result;
32 int main (void)
34 unsigned short dot;
35 int i;
37 check_vect ();
39 for (i=0; i<N; i++) {
40 X[i] = i;
41 Y[i] = 64-i;
44 dot = foo (N);
45 if (dot != DOT)
46 abort ();
48 return 0;
51 /* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" } } */
53 /* When the vectorizer is enhanced to vectorize accumulation into short for
54 targets that support accumulation into int (powerpc, ia64) we'd have:
55 dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_udot_qi || vect_widen_mult_qi_to_hi } }
57 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" {target vect_widen_mult_qi_to_hi} } } */
59 /* { dg-final { cleanup-tree-dump "vect" } } */