libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-reduc-chain-1.c
blob80b0089ea0fa183e39553caa9004a40182a87d6c
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 #define N 50
11 #ifndef SIGNEDNESS_1
12 #define SIGNEDNESS_1 signed
13 #define SIGNEDNESS_2 signed
14 #endif
16 SIGNEDNESS_1 int __attribute__ ((noipa))
17 f (SIGNEDNESS_1 int res,
18 SIGNEDNESS_2 char *restrict a,
19 SIGNEDNESS_2 char *restrict b,
20 SIGNEDNESS_2 char *restrict c,
21 SIGNEDNESS_2 char *restrict d,
22 SIGNEDNESS_1 int *restrict e)
24 for (int i = 0; i < N; ++i)
26 res += a[i] * b[i];
27 res += c[i] * d[i];
28 res += e[i];
30 return res;
33 #define BASE ((SIGNEDNESS_2 int) -1 < 0 ? -126 : 4)
34 #define OFFSET 20
36 int
37 main (void)
39 check_vect ();
41 SIGNEDNESS_2 char a[N], b[N];
42 SIGNEDNESS_2 char c[N], d[N];
43 SIGNEDNESS_1 int e[N];
44 int expected = 0x12345;
46 #pragma GCC novector
47 for (int i = 0; i < N; ++i)
49 a[i] = BASE + i * 5;
50 b[i] = BASE + OFFSET + i * 4;
51 c[i] = BASE + i * 2;
52 d[i] = BASE + OFFSET + i * 3;
53 e[i] = i;
54 expected += a[i] * b[i];
55 expected += c[i] * d[i];
56 expected += e[i];
59 if (f (0x12345, a, b, c, d, e) != expected)
60 __builtin_abort ();
63 /* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */
64 /* { dg-final { scan-tree-dump-times "vectorizing statement: \\S+ = DOT_PROD_EXPR" 2 "vect" { target vect_sdot_qi } } } */