Debian Codegraph @

gcc/testsuite/gcc.dg/vect/vect-reduc-chain-3.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
5 #include "tree-vect.h"
6
7 #define N 50
8
9 #ifndef SIGNEDNESS_1
10 #define SIGNEDNESS_1 signed
11 #define SIGNEDNESS_2 unsigned
12 #define SIGNEDNESS_3 signed
13 #endif
14
15 SIGNEDNESS_1 int __attribute__ ((noipa))
16 f (SIGNEDNESS_1 int res,
17 SIGNEDNESS_2 char *restrict a,
18 SIGNEDNESS_2 char *restrict b,
19 SIGNEDNESS_3 short *restrict c,
20 SIGNEDNESS_3 short *restrict d,
21 SIGNEDNESS_1 int *restrict e)
22 {
23 for (int i = 0; i < N; ++i)
24 {
25 short diff = a[i] - b[i];
26 SIGNEDNESS_2 short abs = diff < 0 ? -diff : diff;
27 res += abs;
28 res += c[i] * d[i];
29 res += e[i];
30 }
31 return res;
32 }
33
34 #define BASE2 ((SIGNEDNESS_2 int) -1 < 0 ? -126 : 4)
35 #define BASE3 ((SIGNEDNESS_3 int) -1 < 0 ? -1236 : 373)
36 #define OFFSET 20
37
38 int
39 main (void)
40 {
41 check_vect ();
42
43 SIGNEDNESS_2 char a[N], b[N];
44 SIGNEDNESS_3 short c[N], d[N];
45 SIGNEDNESS_1 int e[N];
46 int expected = 0x12345;
47
48 #pragma GCC novector
49 for (int i = 0; i < N; ++i)
50 {
51 a[i] = BASE2 + i * 5;
52 b[i] = BASE2 - i * 4;
53 c[i] = BASE3 + i * 2;
54 d[i] = BASE3 + OFFSET + i * 3;
55 e[i] = i;
56 short diff = a[i] - b[i];
57 SIGNEDNESS_2 short abs = diff < 0 ? -diff : diff;
58 expected += abs;
59 expected += c[i] * d[i];
60 expected += e[i];
61 }
62
63 if (f (0x12345, a, b, c, d, e) != expected)
64 __builtin_abort ();
65 }
66
67 /* { dg-final { scan-tree-dump "vectorizing statement: \\S+ = SAD_EXPR" "vect" { target vect_udot_qi } } } */
68 /* { dg-final { scan-tree-dump "vectorizing statement: \\S+ = DOT_PROD_EXPR" "vect" { target vect_sdot_hi } } } */