| 1 |
/* { dg-require-effective-target vect_int } */ |
| 2 |
|
| 3 |
#include <stdarg.h> |
| 4 |
#include "tree-vect.h" |
| 5 |
|
| 6 |
#define N 64 |
| 7 |
|
| 8 |
#define DOT 43680 |
| 9 |
|
| 10 |
signed short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); |
| 11 |
signed short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); |
| 12 |
|
| 13 |
/* short->short->int dot product. Should be vectorized on architectures |
| 14 |
supporting vectorized multiplication of two short args with short result, |
| 15 |
e.g "mulv4hi3" and widenning sum */ |
| 16 |
__attribute__ ((noinline)) int |
| 17 |
foo (int len) |
| 18 |
{ |
| 19 |
int i; |
| 20 |
int result = 0; |
| 21 |
short prod; |
| 22 |
|
| 23 |
for (i = 0; i < len; i++) |
| 24 |
{ |
| 25 |
prod = X[i] * Y[i]; |
| 26 |
result += prod; |
| 27 |
} |
| 28 |
return result; |
| 29 |
} |
| 30 |
|
| 31 |
int |
| 32 |
main (void) |
| 33 |
{ |
| 34 |
int i, dot; |
| 35 |
|
| 36 |
check_vect (); |
| 37 |
|
| 38 |
for (i = 0; i < N; i++) |
| 39 |
{ |
| 40 |
X[i] = i; |
| 41 |
Y[i] = 64 - i; |
| 42 |
__asm__ volatile (""); |
| 43 |
} |
| 44 |
|
| 45 |
dot = foo (N); |
| 46 |
if (dot != DOT) |
| 47 |
abort (); |
| 48 |
|
| 49 |
return 0; |
| 50 |
} |
| 51 |
|
| 52 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_short_mult && { vect_widen_sum_hi_to_si || vect_unpack } } } } } */ |
| 53 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_short_mult } } } } */ |
| 54 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { { ! vect_widen_sum_hi_to_si } && { ! vect_unpack } } } } } */ |
| 55 |
|
| 56 |
|