Debian Codegraph @

gcc/testsuite/gcc.dg/vect/vect-reduc-dot-s16c.c

raw
1 /* { dg-require-effective-target vect_int } */
2
3 #include <stdarg.h>
4 #include "tree-vect.h"
5
6 #define N 64
7 #define DOT 43680
8
9 signed short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
10 signed int Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
11
12 /* (short, int)->int->int dot product.
13 Not detected as a dot-product pattern. */
14
15 __attribute__ ((noinline)) int
16 foo (int len)
17 {
18 int i;
19 int result = 0;
20
21 for (i = 0; i < len; i++)
22 {
23 result += (X[i] * Y[i]);
24 }
25 return result;
26 }
27
28
29 /* (int, short)->int->int dot product.
30 Not detected as a dot-product pattern. */
31
32 __attribute__ ((noinline)) int
33 bar (int len)
34 {
35 int i;
36 int result = 0;
37
38 for (i = 0; i < len; i++)
39 {
40 result += (Y[i] * X[i]);
41 }
42 return result;
43 }
44
45 int
46 main (void)
47 {
48 int i;
49 int dot;
50
51 check_vect ();
52
53 for (i = 0; i < N; i++)
54 {
55 X[i] = i;
56 Y[i] = N - i;
57 __asm__ volatile ("");
58 }
59
60 dot = foo (N);
61 if (dot != DOT)
62 abort ();
63
64 dot = bar (N);
65 if (dot != DOT)
66 abort ();
67
68 return 0;
69 }
70
71 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_unpack } } } */
72