Merged revisions 208012,208018-208019,208021,208023-208030,208033,208037,208040-20804...
[official-gcc.git] / main / gcc / testsuite / gcc.dg / vect / vect-reduc-dot-s16c.c
blob8ba823b044c1ba1a1b57ebe0c3e82f0633b21749
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 64
7 #define DOT 43680
9 signed short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
10 signed int Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
12 /* (short, int)->int->int dot product.
13 Not detected as a dot-product pattern. */
15 __attribute__ ((noinline)) int
16 foo (int len)
18 int i;
19 int result = 0;
21 for (i = 0; i < len; i++)
23 result += (X[i] * Y[i]);
25 return result;
29 /* (int, short)->int->int dot product.
30 Not detected as a dot-product pattern. */
32 __attribute__ ((noinline)) int
33 bar (int len)
35 int i;
36 int result = 0;
38 for (i = 0; i < len; i++)
40 result += (Y[i] * X[i]);
42 return result;
45 int
46 main (void)
48 int i;
49 int dot;
51 check_vect ();
53 for (i = 0; i < N; i++)
55 X[i] = i;
56 Y[i] = N - i;
57 __asm__ volatile ("");
60 dot = foo (N);
61 if (dot != DOT)
62 abort ();
64 dot = bar (N);
65 if (dot != DOT)
66 abort ();
68 return 0;
71 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_unpack } } } */
72 /* { dg-final { cleanup-tree-dump "vect" } } */