| 1 |
/* { dg-skip-if "" { arm*-*-* } } */ |
| 2 |
|
| 3 |
#include <arm_neon.h> |
| 4 |
#include "arm-neon-ref.h" |
| 5 |
#include "compute-ref-data.h" |
| 6 |
|
| 7 |
/* Expected results. */ |
| 8 |
VECT_VAR_DECL(expected, int, 8, 16) [] = { 0x5, 0x5, 0x5, 0x5, |
| 9 |
0x5, 0x5, 0x5, 0x5, |
| 10 |
0xf8, 0xf8, 0xf9, 0xf9, |
| 11 |
0xfa, 0xfa, 0xfb, 0xfb }; |
| 12 |
VECT_VAR_DECL(expected, int, 16, 8) [] = { 0x5, 0x5, 0x5, 0x5, |
| 13 |
0xfff8, 0xfff8, 0xfff9, 0xfff9 }; |
| 14 |
VECT_VAR_DECL(expected, int, 32, 4) [] = { 0x5, 0x5, 0xfffffffc, 0xfffffffc }; |
| 15 |
VECT_VAR_DECL(expected, uint, 8, 16) [] = { 0x5, 0x5, 0x5, 0x5, |
| 16 |
0x5, 0x5, 0x5, 0x5, |
| 17 |
0xfc, 0xfc, 0xfc, 0xfc, |
| 18 |
0xfd, 0xfd, 0xfd, 0xfd }; |
| 19 |
VECT_VAR_DECL(expected, uint, 16, 8) [] = { 0x5, 0x5, 0x5, 0x5, |
| 20 |
0xfffe, 0xfffe, 0xfffe, 0xfffe }; |
| 21 |
VECT_VAR_DECL(expected, uint, 32, 4) [] = { 0x5, 0x5, 0xfffffffe, 0xfffffffe }; |
| 22 |
|
| 23 |
#define TEST_MSG "VSHRN_HIGH_N" |
| 24 |
void exec_vshrn_high_n (void) |
| 25 |
{ |
| 26 |
/* Basic test: y=vshrn_high_n(r,x,v), then store the result. */ |
| 27 |
#define TEST_VSHRN_HIGH_N(T1, T2, W1, W2, N1, N2, V) \ |
| 28 |
VECT_VAR(vector_res, T1, W2, N2) = \ |
| 29 |
vshrn_high_n_##T2##W1(VECT_VAR(vector_res_lo, T1, W2, N1), \ |
| 30 |
VECT_VAR(vector, T1, W1, N1), \ |
| 31 |
V); \ |
| 32 |
vst1q_##T2##W2(VECT_VAR(result, T1, W2, N2), VECT_VAR(vector_res, T1, W2, N2)) |
| 33 |
|
| 34 |
DECL_VARIABLE(vector_res_lo, int, 8, 8); |
| 35 |
DECL_VARIABLE(vector_res_lo, int, 16, 4); |
| 36 |
DECL_VARIABLE(vector_res_lo, int, 32, 2); |
| 37 |
DECL_VARIABLE(vector_res_lo, uint, 8, 8); |
| 38 |
DECL_VARIABLE(vector_res_lo, uint, 16, 4); |
| 39 |
DECL_VARIABLE(vector_res_lo, uint, 32, 2); |
| 40 |
|
| 41 |
DECL_VARIABLE(vector, int, 16, 8); |
| 42 |
DECL_VARIABLE(vector, int, 32, 4); |
| 43 |
DECL_VARIABLE(vector, int, 64, 2); |
| 44 |
DECL_VARIABLE(vector, uint, 16, 8); |
| 45 |
DECL_VARIABLE(vector, uint, 32, 4); |
| 46 |
DECL_VARIABLE(vector, uint, 64, 2); |
| 47 |
|
| 48 |
DECL_VARIABLE(vector_res, int, 8, 16); |
| 49 |
DECL_VARIABLE(vector_res, int, 16, 8); |
| 50 |
DECL_VARIABLE(vector_res, int, 32, 4); |
| 51 |
DECL_VARIABLE(vector_res, uint, 8, 16); |
| 52 |
DECL_VARIABLE(vector_res, uint, 16, 8); |
| 53 |
DECL_VARIABLE(vector_res, uint, 32, 4); |
| 54 |
|
| 55 |
clean_results (); |
| 56 |
|
| 57 |
/* Fill vector_res_lo with a value easy to recognise in the result vector. */ |
| 58 |
VDUP(vector_res_lo, , int, s, 8, 8, 0x5); |
| 59 |
VDUP(vector_res_lo, , int, s, 16, 4, 0x5); |
| 60 |
VDUP(vector_res_lo, , int, s, 32, 2, 0x5); |
| 61 |
VDUP(vector_res_lo, , uint, u, 8, 8, 0x5); |
| 62 |
VDUP(vector_res_lo, , uint, u, 16, 4, 0x5); |
| 63 |
VDUP(vector_res_lo, , uint, u, 32, 2, 0x5); |
| 64 |
|
| 65 |
VLOAD(vector, buffer, q, int, s, 16, 8); |
| 66 |
VLOAD(vector, buffer, q, int, s, 32, 4); |
| 67 |
VLOAD(vector, buffer, q, int, s, 64, 2); |
| 68 |
VLOAD(vector, buffer, q, uint, u, 16, 8); |
| 69 |
VLOAD(vector, buffer, q, uint, u, 32, 4); |
| 70 |
VLOAD(vector, buffer, q, uint, u, 64, 2); |
| 71 |
|
| 72 |
/* Choose shift amount arbitrarily. */ |
| 73 |
TEST_VSHRN_HIGH_N(int, s, 16, 8, 8, 16, 1); |
| 74 |
TEST_VSHRN_HIGH_N(int, s, 32, 16, 4, 8, 1); |
| 75 |
TEST_VSHRN_HIGH_N(int, s, 64, 32, 2, 4, 2); |
| 76 |
TEST_VSHRN_HIGH_N(uint, u, 16, 8, 8, 16, 2); |
| 77 |
TEST_VSHRN_HIGH_N(uint, u, 32, 16, 4, 8, 3); |
| 78 |
TEST_VSHRN_HIGH_N(uint, u, 64, 32, 2, 4, 3); |
| 79 |
|
| 80 |
#define CMT "" |
| 81 |
CHECK(TEST_MSG, int, 8, 16, PRIx8, expected, CMT); |
| 82 |
CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, CMT); |
| 83 |
CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, CMT); |
| 84 |
CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected, CMT); |
| 85 |
CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected, CMT); |
| 86 |
CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, CMT); |
| 87 |
} |
| 88 |
|
| 89 |
int main (void) |
| 90 |
{ |
| 91 |
exec_vshrn_high_n (); |
| 92 |
return 0; |
| 93 |
} |