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