| 1 |
/* { dg-require-effective-target vect_int } */ |
| 2 |
|
| 3 |
#include "tree-vect.h" |
| 4 |
|
| 5 |
#define N 50 |
| 6 |
|
| 7 |
#ifndef SIGNEDNESS_1 |
| 8 |
#define SIGNEDNESS_1 unsigned |
| 9 |
#define SIGNEDNESS_2 unsigned |
| 10 |
#define SIGNEDNESS_3 unsigned |
| 11 |
#endif |
| 12 |
|
| 13 |
SIGNEDNESS_1 int __attribute__ ((noipa)) |
| 14 |
f (SIGNEDNESS_1 int res, SIGNEDNESS_3 char *restrict a, |
| 15 |
SIGNEDNESS_3 char *restrict b) |
| 16 |
{ |
| 17 |
for (__INTPTR_TYPE__ i = 0; i < N; ++i) |
| 18 |
{ |
| 19 |
int av = a[i]; |
| 20 |
int bv = b[i]; |
| 21 |
SIGNEDNESS_2 short mult = av * bv; |
| 22 |
res += mult; |
| 23 |
} |
| 24 |
return res; |
| 25 |
} |
| 26 |
|
| 27 |
#define BASE ((SIGNEDNESS_3 int) -1 < 0 ? -126 : 4) |
| 28 |
#define OFFSET 20 |
| 29 |
|
| 30 |
int |
| 31 |
main (void) |
| 32 |
{ |
| 33 |
check_vect (); |
| 34 |
|
| 35 |
SIGNEDNESS_3 char a[N], b[N]; |
| 36 |
int expected = 0x12345; |
| 37 |
for (int i = 0; i < N; ++i) |
| 38 |
{ |
| 39 |
a[i] = BASE + i * 5; |
| 40 |
b[i] = BASE + OFFSET + i * 4; |
| 41 |
asm volatile ("" ::: "memory"); |
| 42 |
expected += (SIGNEDNESS_2 short) (a[i] * b[i]); |
| 43 |
} |
| 44 |
if (f (0x12345, a, b) != expected) |
| 45 |
__builtin_abort (); |
| 46 |
} |
| 47 |
|
| 48 |
/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */ |
| 49 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_sdot_qi } } } */ |