| 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,16,4) [] = { 0xfff5, 0xfff6, 0xfff7, 0xfff7 }; |
| 7 |
VECT_VAR_DECL(expected,int,32,2) [] = { 0x0, 0x0 }; |
| 8 |
VECT_VAR_DECL(expected,int,16,8) [] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; |
| 9 |
VECT_VAR_DECL(expected,int,32,4) [] = { 0x0, 0x0, 0x0, 0x0 }; |
| 10 |
|
| 11 |
/* Expected results when multiplication saturates. */ |
| 12 |
VECT_VAR_DECL(expected_mul,int,16,4) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff }; |
| 13 |
VECT_VAR_DECL(expected_mul,int,32,2) [] = { 0x7fffffff, 0x7fffffff }; |
| 14 |
VECT_VAR_DECL(expected_mul,int,16,8) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff, |
| 15 |
0x7fff, 0x7fff, 0x7fff, 0x7fff }; |
| 16 |
VECT_VAR_DECL(expected_mul,int,32,4) [] = { 0x7fffffff, 0x7fffffff, |
| 17 |
0x7fffffff, 0x7fffffff }; |
| 18 |
|
| 19 |
/* Expected results when rounding should not cause saturation. */ |
| 20 |
VECT_VAR_DECL(expected_round,int,16,4) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff }; |
| 21 |
VECT_VAR_DECL(expected_round,int,32,2) [] = { 0x7fffffff, 0x7fffffff }; |
| 22 |
VECT_VAR_DECL(expected_round,int,16,8) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff, |
| 23 |
0x7fff, 0x7fff, 0x7fff, 0x7fff }; |
| 24 |
VECT_VAR_DECL(expected_round,int,32,4) [] = { 0x7fffffff, 0x7fffffff, |
| 25 |
0x7fffffff, 0x7fffffff }; |
| 26 |
|
| 27 |
#define INSN vqrdmulh |
| 28 |
#define TEST_MSG "VQRDMULH" |
| 29 |
|
| 30 |
#define FNNAME1(NAME) void exec_ ## NAME (void) |
| 31 |
#define FNNAME(NAME) FNNAME1(NAME) |
| 32 |
|
| 33 |
FNNAME (INSN) |
| 34 |
{ |
| 35 |
/* vector_res = vqrdmulh(vector,vector2), then store the result. */ |
| 36 |
#define TEST_VQRDMULH2(INSN, Q, T1, T2, W, N, CMT) \ |
| 37 |
Set_Neon_Cumulative_Sat(0, VECT_VAR(vector_res, T1, W, N)); \ |
| 38 |
VECT_VAR(vector_res, T1, W, N) = \ |
| 39 |
INSN##Q##_##T2##W(VECT_VAR(vector, T1, W, N), \ |
| 40 |
VECT_VAR(vector2, T1, W, N)); \ |
| 41 |
vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \ |
| 42 |
VECT_VAR(vector_res, T1, W, N)) |
| 43 |
|
| 44 |
/* Two auxliary macros are necessary to expand INSN */ |
| 45 |
#define TEST_VQRDMULH1(INSN, Q, T1, T2, W, N, CMT) \ |
| 46 |
TEST_VQRDMULH2(INSN, Q, T1, T2, W, N, CMT) |
| 47 |
|
| 48 |
#define TEST_VQRDMULH(Q, T1, T2, W, N, CMT) \ |
| 49 |
TEST_VQRDMULH1(INSN, Q, T1, T2, W, N, CMT) |
| 50 |
|
| 51 |
|
| 52 |
DECL_VARIABLE(vector, int, 16, 4); |
| 53 |
DECL_VARIABLE(vector, int, 32, 2); |
| 54 |
DECL_VARIABLE(vector, int, 16, 8); |
| 55 |
DECL_VARIABLE(vector, int, 32, 4); |
| 56 |
|
| 57 |
DECL_VARIABLE(vector_res, int, 16, 4); |
| 58 |
DECL_VARIABLE(vector_res, int, 32, 2); |
| 59 |
DECL_VARIABLE(vector_res, int, 16, 8); |
| 60 |
DECL_VARIABLE(vector_res, int, 32, 4); |
| 61 |
|
| 62 |
DECL_VARIABLE(vector2, int, 16, 4); |
| 63 |
DECL_VARIABLE(vector2, int, 32, 2); |
| 64 |
DECL_VARIABLE(vector2, int, 16, 8); |
| 65 |
DECL_VARIABLE(vector2, int, 32, 4); |
| 66 |
|
| 67 |
clean_results (); |
| 68 |
|
| 69 |
VLOAD(vector, buffer, , int, s, 16, 4); |
| 70 |
VLOAD(vector, buffer, , int, s, 32, 2); |
| 71 |
VLOAD(vector, buffer, q, int, s, 16, 8); |
| 72 |
VLOAD(vector, buffer, q, int, s, 32, 4); |
| 73 |
|
| 74 |
/* Initialize vector2. */ |
| 75 |
VDUP(vector2, , int, s, 16, 4, 0x5555); |
| 76 |
VDUP(vector2, , int, s, 32, 2, 0xBB); |
| 77 |
VDUP(vector2, q, int, s, 16, 8, 0x33); |
| 78 |
VDUP(vector2, q, int, s, 32, 4, 0x22); |
| 79 |
|
| 80 |
#define CMT "" |
| 81 |
TEST_VQRDMULH(, int, s, 16, 4, CMT); |
| 82 |
TEST_VQRDMULH(, int, s, 32, 2, CMT); |
| 83 |
TEST_VQRDMULH(q, int, s, 16, 8, CMT); |
| 84 |
TEST_VQRDMULH(q, int, s, 32, 4, CMT); |
| 85 |
|
| 86 |
CHECK(TEST_MSG, int, 16, 4, PRIx16, expected, CMT); |
| 87 |
CHECK(TEST_MSG, int, 32, 2, PRIx32, expected, CMT); |
| 88 |
CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, CMT); |
| 89 |
CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, CMT); |
| 90 |
|
| 91 |
/* Now use input values such that the multiplication causes |
| 92 |
saturation. */ |
| 93 |
#define TEST_MSG_MUL " (check mul cumulative saturation)" |
| 94 |
VDUP(vector, , int, s, 16, 4, 0x8000); |
| 95 |
VDUP(vector, , int, s, 32, 2, 0x80000000); |
| 96 |
VDUP(vector, q, int, s, 16, 8, 0x8000); |
| 97 |
VDUP(vector, q, int, s, 32, 4, 0x80000000); |
| 98 |
VDUP(vector2, , int, s, 16, 4, 0x8000); |
| 99 |
VDUP(vector2, , int, s, 32, 2, 0x80000000); |
| 100 |
VDUP(vector2, q, int, s, 16, 8, 0x8000); |
| 101 |
VDUP(vector2, q, int, s, 32, 4, 0x80000000); |
| 102 |
|
| 103 |
TEST_VQRDMULH(, int, s, 16, 4, TEST_MSG_MUL); |
| 104 |
TEST_VQRDMULH(, int, s, 32, 2, TEST_MSG_MUL); |
| 105 |
TEST_VQRDMULH(q, int, s, 16, 8, TEST_MSG_MUL); |
| 106 |
TEST_VQRDMULH(q, int, s, 32, 4, TEST_MSG_MUL); |
| 107 |
|
| 108 |
CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_mul, TEST_MSG_MUL); |
| 109 |
CHECK(TEST_MSG, int, 32, 2, PRIx32, expected_mul, TEST_MSG_MUL); |
| 110 |
CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_mul, TEST_MSG_MUL); |
| 111 |
CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_mul, TEST_MSG_MUL); |
| 112 |
|
| 113 |
/* Use input values where rounding produces a result equal to the |
| 114 |
saturation value, but does not set the saturation flag. */ |
| 115 |
#define TEST_MSG_ROUND " (check rounding)" |
| 116 |
VDUP(vector, , int, s, 16, 4, 0x8000); |
| 117 |
VDUP(vector, , int, s, 32, 2, 0x80000000); |
| 118 |
VDUP(vector, q, int, s, 16, 8, 0x8000); |
| 119 |
VDUP(vector, q, int, s, 32, 4, 0x80000000); |
| 120 |
VDUP(vector2, , int, s, 16, 4, 0x8001); |
| 121 |
VDUP(vector2, , int, s, 32, 2, 0x80000001); |
| 122 |
VDUP(vector2, q, int, s, 16, 8, 0x8001); |
| 123 |
VDUP(vector2, q, int, s, 32, 4, 0x80000001); |
| 124 |
|
| 125 |
TEST_VQRDMULH(, int, s, 16, 4, TEST_MSG_ROUND); |
| 126 |
TEST_VQRDMULH(, int, s, 32, 2, TEST_MSG_ROUND); |
| 127 |
TEST_VQRDMULH(q, int, s, 16, 8, TEST_MSG_ROUND); |
| 128 |
TEST_VQRDMULH(q, int, s, 32, 4, TEST_MSG_ROUND); |
| 129 |
|
| 130 |
CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_round, TEST_MSG_ROUND); |
| 131 |
CHECK(TEST_MSG, int, 32, 2, PRIx32, expected_round, TEST_MSG_ROUND); |
| 132 |
CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_round, TEST_MSG_ROUND); |
| 133 |
CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_round, TEST_MSG_ROUND); |
| 134 |
} |
| 135 |
|
| 136 |
int main (void) |
| 137 |
{ |
| 138 |
exec_vqrdmulh (); |
| 139 |
return 0; |
| 140 |
} |