Debian Codegraph @

gcc/testsuite/gcc.dg/vect/vect-reduc-chain-dot-slp-1.c

raw
1 /* Disabling epilogues until we find a better way to deal with scans. */
2 /* { dg-additional-options "--param vect-epilogues-nomask=0" } */
3 /* { dg-require-effective-target vect_int } */
4 /* { dg-require-effective-target arm_v8_2a_dotprod_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */
5 /* { dg-add-options arm_v8_2a_dotprod_neon } */
6
7 #include "tree-vect.h"
8
9 #ifndef SIGNEDNESS_1
10 #define SIGNEDNESS_1 signed
11 #define SIGNEDNESS_2 signed
12 #endif
13
14 SIGNEDNESS_1 int __attribute__ ((noipa))
15 f (SIGNEDNESS_1 int res,
16 SIGNEDNESS_2 char *a,
17 SIGNEDNESS_2 char *b,
18 int step, int n)
19 {
20 for (int i = 0; i < n; i++)
21 {
22 res += a[0] * b[0];
23 res += a[1] * b[1];
24 res += a[2] * b[2];
25 res += a[3] * b[3];
26 res += a[4] * b[4];
27 res += a[5] * b[5];
28 res += a[6] * b[6];
29 res += a[7] * b[7];
30 res += a[8] * b[8];
31 res += a[9] * b[9];
32 res += a[10] * b[10];
33 res += a[11] * b[11];
34 res += a[12] * b[12];
35 res += a[13] * b[13];
36 res += a[14] * b[14];
37 res += a[15] * b[15];
38
39 a += step;
40 b += step;
41 }
42
43 return res;
44 }
45
46 #define BASE ((SIGNEDNESS_2 int) -1 < 0 ? -126 : 4)
47 #define OFFSET 20
48
49 int
50 main (void)
51 {
52 check_vect ();
53
54 SIGNEDNESS_2 char a[100], b[100];
55 int expected = 0x12345;
56 int step = 16;
57 int n = 2;
58 int t = 0;
59
60 #pragma GCC novector
61 for (int i = 0; i < sizeof (a) / sizeof (a[0]); ++i)
62 {
63 a[i] = BASE + i * 5;
64 b[i] = BASE + OFFSET + i * 4;
65 }
66
67 #pragma GCC novector
68 for (int i = 0; i < n; i++)
69 {
70 expected += a[t + 0] * b[t + 0];
71 expected += a[t + 1] * b[t + 1];
72 expected += a[t + 2] * b[t + 2];
73 expected += a[t + 3] * b[t + 3];
74 expected += a[t + 4] * b[t + 4];
75 expected += a[t + 5] * b[t + 5];
76 expected += a[t + 6] * b[t + 6];
77 expected += a[t + 7] * b[t + 7];
78 expected += a[t + 8] * b[t + 8];
79 expected += a[t + 9] * b[t + 9];
80 expected += a[t + 10] * b[t + 10];
81 expected += a[t + 11] * b[t + 11];
82 expected += a[t + 12] * b[t + 12];
83 expected += a[t + 13] * b[t + 13];
84 expected += a[t + 14] * b[t + 14];
85 expected += a[t + 15] * b[t + 15];
86 t += step;
87 }
88
89 if (f (0x12345, a, b, step, n) != expected)
90 __builtin_abort ();
91 }
92
93 /* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */
94 /* { dg-final { scan-tree-dump "vectorizing SLP node starting from: \\S+ = DOT_PROD_EXPR" "vect" { target vect_sdot_qi } } } */