| 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 with input=0. */ |
| 8 |
VECT_VAR_DECL(expected_0, int, 8, 16) [] = { 0x5, 0x5, 0x5, 0x5, |
| 9 |
0x5, 0x5, 0x5, 0x5, |
| 10 |
0x0, 0x0, 0x0, 0x0, |
| 11 |
0x0, 0x0, 0x0, 0x0 }; |
| 12 |
VECT_VAR_DECL(expected_0, int, 16, 8) [] = { 0x5, 0x5, 0x5, 0x5, |
| 13 |
0x0, 0x0, 0x0, 0x0 }; |
| 14 |
VECT_VAR_DECL(expected_0, int, 32, 4) [] = { 0x5, 0x5, 0x0, 0x0 }; |
| 15 |
VECT_VAR_DECL(expected_0, uint, 8, 16) [] = { 0x5, 0x5, 0x5, 0x5, |
| 16 |
0x5, 0x5, 0x5, 0x5, |
| 17 |
0x0, 0x0, 0x0, 0x0, |
| 18 |
0x0, 0x0, 0x0, 0x0 }; |
| 19 |
VECT_VAR_DECL(expected_0, uint, 16, 8) [] = { 0x5, 0x5, 0x5, 0x5, |
| 20 |
0x0, 0x0, 0x0, 0x0 }; |
| 21 |
VECT_VAR_DECL(expected_0, uint, 32, 4) [] = { 0x5, 0x5, 0x0, 0x0 }; |
| 22 |
|
| 23 |
/* Expected results. */ |
| 24 |
VECT_VAR_DECL(expected, int, 8, 16) [] = { 0x5, 0x5, 0x5, 0x5, |
| 25 |
0x5, 0x5, 0x5, 0x5, |
| 26 |
0xf8, 0xf9, 0xf9, 0xfa, |
| 27 |
0xfa, 0xfb, 0xfb, 0xfc }; |
| 28 |
VECT_VAR_DECL(expected, int, 16, 8) [] = { 0x5, 0x5, 0x5, 0x5, |
| 29 |
0xfff8, 0xfff9, 0xfff9, 0xfffa }; |
| 30 |
VECT_VAR_DECL(expected, int, 32, 4) [] = { 0x5, 0x5, 0xfffffffc, 0xfffffffc }; |
| 31 |
VECT_VAR_DECL(expected, uint, 8, 16) [] = { 0x5, 0x5, 0x5, 0x5, |
| 32 |
0x5, 0x5, 0x5, 0x5, |
| 33 |
0xfc, 0xfc, 0xfd, 0xfd, |
| 34 |
0xfd, 0xfd, 0xfe, 0xfe }; |
| 35 |
VECT_VAR_DECL(expected, uint, 16, 8) [] = { 0x5, 0x5, 0x5, 0x5, |
| 36 |
0xfffe, 0xfffe, 0xfffe, 0xfffe }; |
| 37 |
VECT_VAR_DECL(expected, uint, 32, 4) [] = { 0x5, 0x5, 0xfffffffe, 0xfffffffe }; |
| 38 |
|
| 39 |
/* Expected results with large shift amount. */ |
| 40 |
VECT_VAR_DECL(expected_sh_large, int, 8, 16) [] = { 0x5, 0x5, 0x5, 0x5, |
| 41 |
0x5, 0x5, 0x5, 0x5, |
| 42 |
0x0, 0x0, 0x0, 0x0, |
| 43 |
0x0, 0x0, 0x0, 0x0 }; |
| 44 |
VECT_VAR_DECL(expected_sh_large, int, 16, 8) [] = { 0x5, 0x5, 0x5, 0x5, |
| 45 |
0x0, 0x0, 0x0, 0x0 }; |
| 46 |
VECT_VAR_DECL(expected_sh_large, int, 32, 4) [] = { 0x5, 0x5, 0x0, 0x0 }; |
| 47 |
VECT_VAR_DECL(expected_sh_large, uint, 8, 16) [] = { 0x5, 0x5, 0x5, 0x5, |
| 48 |
0x5, 0x5, 0x5, 0x5, |
| 49 |
0x0, 0x0, 0x0, 0x0, |
| 50 |
0x0, 0x0, 0x0, 0x0 }; |
| 51 |
VECT_VAR_DECL(expected_sh_large, uint, 16, 8) [] = { 0x5, 0x5, 0x5, 0x5, |
| 52 |
0x0, 0x0, 0x0, 0x0 }; |
| 53 |
VECT_VAR_DECL(expected_sh_large, uint, 32, 4) [] = { 0x5, 0x5, 0x0, 0x0 }; |
| 54 |
|
| 55 |
#define TEST_MSG "VRSHRN_HIGH_N" |
| 56 |
void exec_vrshrn_high_n (void) |
| 57 |
{ |
| 58 |
/* Basic test: y=vrshrn_high_n(r,x,v), then store the result. */ |
| 59 |
#define TEST_VRSHRN_HIGH_N(T1, T2, W1, W2, N1, N2, V) \ |
| 60 |
VECT_VAR(vector_res, T1, W2, N2) = \ |
| 61 |
vrshrn_high_n_##T2##W1(VECT_VAR(vector_res_lo, T1, W2, N1), \ |
| 62 |
VECT_VAR(vector, T1, W1, N1), \ |
| 63 |
V); \ |
| 64 |
vst1q_##T2##W2(VECT_VAR(result, T1, W2, N2), VECT_VAR(vector_res, T1, W2, N2)) |
| 65 |
|
| 66 |
DECL_VARIABLE(vector_res_lo, int, 8, 8); |
| 67 |
DECL_VARIABLE(vector_res_lo, int, 16, 4); |
| 68 |
DECL_VARIABLE(vector_res_lo, int, 32, 2); |
| 69 |
DECL_VARIABLE(vector_res_lo, uint, 8, 8); |
| 70 |
DECL_VARIABLE(vector_res_lo, uint, 16, 4); |
| 71 |
DECL_VARIABLE(vector_res_lo, uint, 32, 2); |
| 72 |
|
| 73 |
DECL_VARIABLE(vector, int, 16, 8); |
| 74 |
DECL_VARIABLE(vector, int, 32, 4); |
| 75 |
DECL_VARIABLE(vector, int, 64, 2); |
| 76 |
DECL_VARIABLE(vector, uint, 16, 8); |
| 77 |
DECL_VARIABLE(vector, uint, 32, 4); |
| 78 |
DECL_VARIABLE(vector, uint, 64, 2); |
| 79 |
|
| 80 |
DECL_VARIABLE(vector_res, int, 8, 16); |
| 81 |
DECL_VARIABLE(vector_res, int, 16, 8); |
| 82 |
DECL_VARIABLE(vector_res, int, 32, 4); |
| 83 |
DECL_VARIABLE(vector_res, uint, 8, 16); |
| 84 |
DECL_VARIABLE(vector_res, uint, 16, 8); |
| 85 |
DECL_VARIABLE(vector_res, uint, 32, 4); |
| 86 |
|
| 87 |
clean_results (); |
| 88 |
|
| 89 |
/* Fill vector_res_lo with a value easy to recognise in the result vector. */ |
| 90 |
VDUP(vector_res_lo, , int, s, 8, 8, 0x5); |
| 91 |
VDUP(vector_res_lo, , int, s, 16, 4, 0x5); |
| 92 |
VDUP(vector_res_lo, , int, s, 32, 2, 0x5); |
| 93 |
VDUP(vector_res_lo, , uint, u, 8, 8, 0x5); |
| 94 |
VDUP(vector_res_lo, , uint, u, 16, 4, 0x5); |
| 95 |
VDUP(vector_res_lo, , uint, u, 32, 2, 0x5); |
| 96 |
|
| 97 |
/* Fill input vector with 0, to check behavior on limits. */ |
| 98 |
VDUP(vector, q, int, s, 16, 8, 0); |
| 99 |
VDUP(vector, q, int, s, 32, 4, 0); |
| 100 |
VDUP(vector, q, int, s, 64, 2, 0); |
| 101 |
VDUP(vector, q, uint, u, 16, 8, 0); |
| 102 |
VDUP(vector, q, uint, u, 32, 4, 0); |
| 103 |
VDUP(vector, q, uint, u, 64, 2, 0); |
| 104 |
|
| 105 |
/* Choose shift amount arbitrarily. */ |
| 106 |
TEST_VRSHRN_HIGH_N(int, s, 16, 8, 8, 16, 1); |
| 107 |
TEST_VRSHRN_HIGH_N(int, s, 32, 16, 4, 8, 1); |
| 108 |
TEST_VRSHRN_HIGH_N(int, s, 64, 32, 2, 4, 2); |
| 109 |
TEST_VRSHRN_HIGH_N(uint, u, 16, 8, 8, 16, 2); |
| 110 |
TEST_VRSHRN_HIGH_N(uint, u, 32, 16, 4, 8, 3); |
| 111 |
TEST_VRSHRN_HIGH_N(uint, u, 64, 32, 2, 4, 3); |
| 112 |
|
| 113 |
#define CMT " (with input = 0)" |
| 114 |
CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_0, CMT); |
| 115 |
CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_0, CMT); |
| 116 |
CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_0, CMT); |
| 117 |
CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_0, CMT); |
| 118 |
CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_0, CMT); |
| 119 |
CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_0, CMT); |
| 120 |
|
| 121 |
|
| 122 |
/* Test again, with predefined input values. */ |
| 123 |
VLOAD(vector, buffer, q, int, s, 16, 8); |
| 124 |
VLOAD(vector, buffer, q, int, s, 32, 4); |
| 125 |
VLOAD(vector, buffer, q, int, s, 64, 2); |
| 126 |
VLOAD(vector, buffer, q, uint, u, 16, 8); |
| 127 |
VLOAD(vector, buffer, q, uint, u, 32, 4); |
| 128 |
VLOAD(vector, buffer, q, uint, u, 64, 2); |
| 129 |
|
| 130 |
/* Choose shift amount arbitrarily. */ |
| 131 |
TEST_VRSHRN_HIGH_N(int, s, 16, 8, 8, 16, 1); |
| 132 |
TEST_VRSHRN_HIGH_N(int, s, 32, 16, 4, 8, 1); |
| 133 |
TEST_VRSHRN_HIGH_N(int, s, 64, 32, 2, 4, 2); |
| 134 |
TEST_VRSHRN_HIGH_N(uint, u, 16, 8, 8, 16, 2); |
| 135 |
TEST_VRSHRN_HIGH_N(uint, u, 32, 16, 4, 8, 3); |
| 136 |
TEST_VRSHRN_HIGH_N(uint, u, 64, 32, 2, 4, 3); |
| 137 |
|
| 138 |
#undef CMT |
| 139 |
#define CMT "" |
| 140 |
CHECK(TEST_MSG, int, 8, 16, PRIx8, expected, CMT); |
| 141 |
CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, CMT); |
| 142 |
CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, CMT); |
| 143 |
CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected, CMT); |
| 144 |
CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected, CMT); |
| 145 |
CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, CMT); |
| 146 |
|
| 147 |
/* Fill input arbitrary values. */ |
| 148 |
VDUP(vector, q, int, s, 16, 8, 30); |
| 149 |
VDUP(vector, q, int, s, 32, 4, 0); |
| 150 |
VDUP(vector, q, int, s, 64, 2, 0); |
| 151 |
VDUP(vector, q, uint, u, 16, 8, 0xFFF0); |
| 152 |
VDUP(vector, q, uint, u, 32, 4, 0xFFFFFFF0); |
| 153 |
VDUP(vector, q, uint, u, 64, 2, 0); |
| 154 |
|
| 155 |
/* Choose large shift amount arbitrarily. */ |
| 156 |
TEST_VRSHRN_HIGH_N(int, s, 16, 8, 8, 16, 7); |
| 157 |
TEST_VRSHRN_HIGH_N(int, s, 32, 16, 4, 8, 14); |
| 158 |
TEST_VRSHRN_HIGH_N(int, s, 64, 32, 2, 4, 31); |
| 159 |
TEST_VRSHRN_HIGH_N(uint, u, 16, 8, 8, 16, 7); |
| 160 |
TEST_VRSHRN_HIGH_N(uint, u, 32, 16, 4, 8, 16); |
| 161 |
TEST_VRSHRN_HIGH_N(uint, u, 64, 32, 2, 4, 3); |
| 162 |
|
| 163 |
#undef CMT |
| 164 |
#define CMT " (with large shift amount)" |
| 165 |
CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_sh_large, CMT); |
| 166 |
CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_sh_large, CMT); |
| 167 |
CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_sh_large, CMT); |
| 168 |
CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_sh_large, CMT); |
| 169 |
CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_sh_large, CMT); |
| 170 |
CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_sh_large, CMT); |
| 171 |
} |
| 172 |
|
| 173 |
int main (void) |
| 174 |
{ |
| 175 |
exec_vrshrn_high_n (); |
| 176 |
return 0; |
| 177 |
} |