| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-require-effective-target vect_dotprod_hisi } */ |
| 3 |
/* Ensure that, given the same input datatype, both the two-way and four-way |
| 4 |
dot products are autovectorized, with the correct operation then selected |
| 5 |
based on the distinct output types. */ |
| 6 |
#include <stdint.h> |
| 7 |
|
| 8 |
uint32_t udot4(int n, uint8_t* data) { |
| 9 |
uint32_t sum = 0; |
| 10 |
for (int i=0; i<n; i+=1) { |
| 11 |
sum += data[i] * data[i]; |
| 12 |
} |
| 13 |
return sum; |
| 14 |
} |
| 15 |
|
| 16 |
int32_t sdot4(int n, int8_t* data) { |
| 17 |
int32_t sum = 0; |
| 18 |
for (int i=0; i<n; i+=1) { |
| 19 |
sum += data[i] * data[i]; |
| 20 |
} |
| 21 |
return sum; |
| 22 |
} |
| 23 |
|
| 24 |
uint32_t udot2(int n, uint16_t* data) { |
| 25 |
uint32_t sum = 0; |
| 26 |
for (int i=0; i<n; i+=1) { |
| 27 |
sum += data[i] * data[i]; |
| 28 |
} |
| 29 |
return sum; |
| 30 |
} |
| 31 |
|
| 32 |
int32_t sdot2(int n, int16_t* data) { |
| 33 |
int32_t sum = 0; |
| 34 |
for (int i=0; i<n; i+=1) { |
| 35 |
sum += data[i] * data[i]; |
| 36 |
} |
| 37 |
return sum; |
| 38 |
} |
| 39 |
|
| 40 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 4 "vect" } } */ |
| 41 |
/* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 4 "vect" } } */ |