libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-reduc-chain-dot-slp-2.c
blob818eeddcece190d559d19056712fc6dc5fcafe31
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 } */
7 #include "tree-vect.h"
9 #ifndef SIGNEDNESS_1
10 #define SIGNEDNESS_1 signed
11 #define SIGNEDNESS_2 signed
12 #endif
14 SIGNEDNESS_1 int __attribute__ ((noipa))
15 f (SIGNEDNESS_1 int res,
16 SIGNEDNESS_2 char *a,
17 SIGNEDNESS_2 char *b,
18 int n)
20 for (int i = 0; i < n; i++)
22 res += a[5 * i + 0] * b[5 * i + 0];
23 res += a[5 * i + 1] * b[5 * i + 1];
24 res += a[5 * i + 2] * b[5 * i + 2];
25 res += a[5 * i + 3] * b[5 * i + 3];
26 res += a[5 * i + 4] * b[5 * i + 4];
29 return res;
32 #define BASE ((SIGNEDNESS_2 int) -1 < 0 ? -126 : 4)
33 #define OFFSET 20
35 int
36 main (void)
38 check_vect ();
40 SIGNEDNESS_2 char a[100], b[100];
41 int expected = 0x12345;
42 int n = 18;
44 #pragma GCC novector
45 for (int i = 0; i < sizeof (a) / sizeof (a[0]); ++i)
47 a[i] = BASE + i * 5;
48 b[i] = BASE + OFFSET + i * 4;
51 #pragma GCC novector
52 for (int i = 0; i < n; i++)
54 expected += a[5 * i + 0] * b[5 * i + 0];
55 expected += a[5 * i + 1] * b[5 * i + 1];
56 expected += a[5 * i + 2] * b[5 * i + 2];
57 expected += a[5 * i + 3] * b[5 * i + 3];
58 expected += a[5 * i + 4] * b[5 * i + 4];
61 if (f (0x12345, a, b, n) != expected)
62 __builtin_abort ();
65 /* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */
66 /* { dg-final { scan-tree-dump "vectorizing SLP node starting from: \\S+ = DOT_PROD_EXPR" "vect" { target vect_sdot_qi } } } */