| 1 |
#include <arm_neon.h> |
| 2 |
#include "arm-neon-ref.h" |
| 3 |
#include "compute-ref-data.h" |
| 4 |
|
| 5 |
/* Expected results. */ |
| 6 |
VECT_VAR_DECL(expected,int,8,16) [] = { 0xf0, 0xf1, 0xf2, 0xf3, |
| 7 |
0xf4, 0xf5, 0xf6, 0xf7, |
| 8 |
0x11, 0x11, 0x11, 0x11, |
| 9 |
0x11, 0x11, 0x11, 0x11 }; |
| 10 |
VECT_VAR_DECL(expected,int,16,8) [] = { 0xfff0, 0xfff1, 0xfff2, 0xfff3, |
| 11 |
0x22, 0x22, 0x22, 0x22 }; |
| 12 |
VECT_VAR_DECL(expected,int,32,4) [] = { 0xfffffff0, 0xfffffff1, 0x33, 0x33 }; |
| 13 |
VECT_VAR_DECL(expected,int,64,2) [] = { 0xfffffffffffffff0, 0x44 }; |
| 14 |
VECT_VAR_DECL(expected,uint,8,16) [] = { 0xf0, 0xf1, 0xf2, 0xf3, |
| 15 |
0xf4, 0xf5, 0xf6, 0xf7, |
| 16 |
0x55, 0x55, 0x55, 0x55, |
| 17 |
0x55, 0x55, 0x55, 0x55 }; |
| 18 |
VECT_VAR_DECL(expected,uint,16,8) [] = { 0xfff0, 0xfff1, 0xfff2, 0xfff3, |
| 19 |
0x66, 0x66, 0x66, 0x66 }; |
| 20 |
VECT_VAR_DECL(expected,uint,32,4) [] = { 0xfffffff0, 0xfffffff1, 0x77, 0x77 }; |
| 21 |
VECT_VAR_DECL(expected,uint,64,2) [] = { 0xfffffffffffffff0, 0x88 }; |
| 22 |
VECT_VAR_DECL(expected,poly,8,16) [] = { 0xf0, 0xf1, 0xf2, 0xf3, |
| 23 |
0xf4, 0xf5, 0xf6, 0xf7, |
| 24 |
0x55, 0x55, 0x55, 0x55, |
| 25 |
0x55, 0x55, 0x55, 0x55 }; |
| 26 |
VECT_VAR_DECL(expected,poly,16,8) [] = { 0xfff0, 0xfff1, 0xfff2, 0xfff3, |
| 27 |
0x66, 0x66, 0x66, 0x66 }; |
| 28 |
#if MFLOAT8_SUPPORTED |
| 29 |
VECT_VAR_DECL(expected,hmfloat,8,16) [] = { 0xf0, 0xf1, 0xf2, 0xf3, |
| 30 |
0xf4, 0xf5, 0xf6, 0xf7, |
| 31 |
0xcc, 0xcc, 0xcc, 0xcc, |
| 32 |
0xcc, 0xcc, 0xcc, 0xcc }; |
| 33 |
#endif |
| 34 |
VECT_VAR_DECL(expected,hfloat,32,4) [] = { 0xc1800000, 0xc1700000, |
| 35 |
0x40533333, 0x40533333 }; |
| 36 |
VECT_VAR_DECL(expected,hfloat,16,8) [] = { 0xcc00, 0xcb80, 0xcb00, 0xca80, |
| 37 |
0x4080, 0x4080, 0x4080, 0x4080 }; |
| 38 |
|
| 39 |
#define TEST_MSG "VCOMBINE" |
| 40 |
void exec_vcombine (void) |
| 41 |
{ |
| 42 |
/* Basic test: vec128=vcombine(vec64_a, vec64_b), then store the result. */ |
| 43 |
#define TEST_VCOMBINE(T1, T2, W, N, N2) \ |
| 44 |
VECT_VAR(vector128, T1, W, N2) = \ |
| 45 |
vcombine_##T2##W(VECT_VAR(vector64_a, T1, W, N), \ |
| 46 |
VECT_VAR(vector64_b, T1, W, N)); \ |
| 47 |
vst1q_##T2##W(VECT_VAR(result, T1, W, N2), VECT_VAR(vector128, T1, W, N2)) |
| 48 |
|
| 49 |
DECL_VARIABLE_64BITS_VARIANTS(vector64_a); |
| 50 |
DECL_VARIABLE_64BITS_VARIANTS(vector64_b); |
| 51 |
DECL_VARIABLE_128BITS_VARIANTS(vector128); |
| 52 |
|
| 53 |
/* Initialize input "vector64_a" from "buffer". */ |
| 54 |
TEST_MACRO_64BITS_VARIANTS_2_5(VLOAD, vector64_a, buffer); |
| 55 |
MFLOAT8_ONLY(VLOAD(vector64_a, buffer, , mfloat, mf, 8, 8);) |
| 56 |
#if defined (__ARM_FP16_FORMAT_IEEE) || defined (__ARM_FP16_FORMAT_ALTERNATIVE) |
| 57 |
VLOAD(vector64_a, buffer, , float, f, 16, 4); |
| 58 |
#endif |
| 59 |
VLOAD(vector64_a, buffer, , float, f, 32, 2); |
| 60 |
|
| 61 |
/* Choose init value arbitrarily. */ |
| 62 |
VDUP(vector64_b, , int, s, 8, 8, 0x11); |
| 63 |
VDUP(vector64_b, , int, s, 16, 4, 0x22); |
| 64 |
VDUP(vector64_b, , int, s, 32, 2, 0x33); |
| 65 |
VDUP(vector64_b, , int, s, 64, 1, 0x44); |
| 66 |
VDUP(vector64_b, , uint, u, 8, 8, 0x55); |
| 67 |
VDUP(vector64_b, , uint, u, 16, 4, 0x66); |
| 68 |
VDUP(vector64_b, , uint, u, 32, 2, 0x77); |
| 69 |
VDUP(vector64_b, , uint, u, 64, 1, 0x88); |
| 70 |
VDUP(vector64_b, , poly, p, 8, 8, 0x55); |
| 71 |
VDUP(vector64_b, , poly, p, 16, 4, 0x66); |
| 72 |
MFLOAT8_ONLY(VDUP(vector64_b, , mfloat, mf, 8, 8, MFLOAT8(0xcc));) |
| 73 |
#if defined (__ARM_FP16_FORMAT_IEEE) || defined (__ARM_FP16_FORMAT_ALTERNATIVE) |
| 74 |
VDUP(vector64_b, , float, f, 16, 4, 2.25); |
| 75 |
#endif |
| 76 |
VDUP(vector64_b, , float, f, 32, 2, 3.3f); |
| 77 |
|
| 78 |
clean_results (); |
| 79 |
|
| 80 |
/* Execute the tests. */ |
| 81 |
TEST_VCOMBINE(int, s, 8, 8, 16); |
| 82 |
TEST_VCOMBINE(int, s, 16, 4, 8); |
| 83 |
TEST_VCOMBINE(int, s, 32, 2, 4); |
| 84 |
TEST_VCOMBINE(int, s, 64, 1, 2); |
| 85 |
TEST_VCOMBINE(uint, u, 8, 8, 16); |
| 86 |
TEST_VCOMBINE(uint, u, 16, 4, 8); |
| 87 |
TEST_VCOMBINE(uint, u, 32, 2, 4); |
| 88 |
TEST_VCOMBINE(uint, u, 64, 1, 2); |
| 89 |
TEST_VCOMBINE(poly, p, 8, 8, 16); |
| 90 |
TEST_VCOMBINE(poly, p, 16, 4, 8); |
| 91 |
MFLOAT8_ONLY(TEST_VCOMBINE(mfloat, mf, 8, 8, 16);) |
| 92 |
#if defined (__ARM_FP16_FORMAT_IEEE) || defined (__ARM_FP16_FORMAT_ALTERNATIVE) |
| 93 |
TEST_VCOMBINE(float, f, 16, 4, 8); |
| 94 |
#endif |
| 95 |
TEST_VCOMBINE(float, f, 32, 2, 4); |
| 96 |
|
| 97 |
CHECK(TEST_MSG, int, 8, 16, PRIx8, expected, ""); |
| 98 |
CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, ""); |
| 99 |
CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, ""); |
| 100 |
CHECK(TEST_MSG, int, 64, 2, PRIx64, expected, ""); |
| 101 |
CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected, ""); |
| 102 |
CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected, ""); |
| 103 |
CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, ""); |
| 104 |
CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected, ""); |
| 105 |
CHECK_POLY(TEST_MSG, poly, 8, 16, PRIx8, expected, ""); |
| 106 |
CHECK_POLY(TEST_MSG, poly, 16, 8, PRIx16, expected, ""); |
| 107 |
MFLOAT8_ONLY(CHECK_FP(TEST_MSG, mfloat, 8, 16, PRIx16, expected, "");) |
| 108 |
#if defined (__ARM_FP16_FORMAT_IEEE) || defined (__ARM_FP16_FORMAT_ALTERNATIVE) |
| 109 |
CHECK_FP(TEST_MSG, float, 16, 8, PRIx16, expected, ""); |
| 110 |
#endif |
| 111 |
CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected, ""); |
| 112 |
} |
| 113 |
|
| 114 |
int main (void) |
| 115 |
{ |
| 116 |
exec_vcombine (); |
| 117 |
return 0; |
| 118 |
} |