| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-require-effective-target vect_dotprod_hisi } */ |
| 3 |
/* { dg-options "-static -O3 -ftree-vectorize -fdump-tree-vect-details -save-temps" } */ |
| 4 |
/* Ensure runtime correctness in the autovectorized two-way dot product operations. */ |
| 5 |
|
| 6 |
#include <stdint.h> |
| 7 |
#include <stdlib.h> |
| 8 |
#pragma GCC target "+sme2" |
| 9 |
|
| 10 |
uint32_t |
| 11 |
udot2 (int n, uint16_t* data) __arm_streaming |
| 12 |
{ |
| 13 |
uint32_t sum = 0; |
| 14 |
for (int i=0; i<n; i+=1) { |
| 15 |
sum += data[i] * data[i]; |
| 16 |
} |
| 17 |
return sum; |
| 18 |
} |
| 19 |
|
| 20 |
int32_t |
| 21 |
sdot2 (int n, int16_t* data) __arm_streaming |
| 22 |
{ |
| 23 |
int32_t sum = 0; |
| 24 |
for (int i=0; i<n; i+=1) { |
| 25 |
sum += data[i] * data[i]; |
| 26 |
} |
| 27 |
return sum; |
| 28 |
} |
| 29 |
|
| 30 |
int |
| 31 |
main () |
| 32 |
{ |
| 33 |
|
| 34 |
uint16_t u_input_nil[] = { [0 ... 3] = 0 }; |
| 35 |
uint16_t u_input_min[] = { [0 ... 3] = 1 }; |
| 36 |
uint16_t u_input_max[] = { [0 ... 3] = 32767}; |
| 37 |
|
| 38 |
uint32_t u_nil_dotprod = udot2 (4, u_input_nil); |
| 39 |
uint32_t u_min_dotprod = udot2 (4, u_input_min); |
| 40 |
uint32_t u_max_dotprod = udot2 (4, u_input_max); |
| 41 |
|
| 42 |
if (u_nil_dotprod != 0 |
| 43 |
|| u_min_dotprod != 4 |
| 44 |
|| u_max_dotprod != 4294705156) |
| 45 |
abort (); |
| 46 |
|
| 47 |
int16_t s_input_nil[] = { [0 ... 3] = 0 }; |
| 48 |
int16_t s_input_min[] = { [0 ... 3] = -23170 }; |
| 49 |
int16_t s_input_max[] = { [0 ... 3] = 23170 }; |
| 50 |
|
| 51 |
int32_t s_nil_dotprod = sdot2 (4, s_input_nil); |
| 52 |
int32_t s_min_dotprod = sdot2 (4, s_input_min); |
| 53 |
int32_t s_max_dotprod = sdot2 (4, s_input_max); |
| 54 |
|
| 55 |
if (s_nil_dotprod != 0 |
| 56 |
|| s_min_dotprod != 2147395600 |
| 57 |
|| s_max_dotprod != 2147395600) |
| 58 |
abort (); |
| 59 |
|
| 60 |
return 0; |
| 61 |
} |
| 62 |
|
| 63 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */ |
| 64 |
/* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 46 "vect" } } */ |
| 65 |
/* { dg-final { scan-assembler "\[ \t\]udot\tz\[0-9\]+.s, z\[0-9\]+.h, z\[0-9\]+.h" } } */ |
| 66 |
/* { dg-final { scan-assembler "\[ \t\]sdot\tz\[0-9\]+.s, z\[0-9\]+.h, z\[0-9\]+.h" } } */ |