| 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 negative input. */ |
| 8 |
VECT_VAR_DECL(expected_neg,uint,8,16) [] = { 0xfe, 0xfe, 0xfe, 0xfe, |
| 9 |
0xfe, 0xfe, 0xfe, 0xfe, |
| 10 |
0x0, 0x0, 0x0, 0x0, |
| 11 |
0x0,0x0, 0x0, 0x0 }; |
| 12 |
VECT_VAR_DECL(expected_neg,uint,16,8) [] = { 0xfffd, 0xfffd, 0xfffd, 0xfffd, |
| 13 |
0x0, 0x0, 0x0, 0x0, 0x0 }; |
| 14 |
VECT_VAR_DECL(expected_neg,uint,32,4) [] = { 0xfffffffc, 0xfffffffc, |
| 15 |
0x0, 0x0 }; |
| 16 |
|
| 17 |
/* Expected results with max input value shifted by 1. */ |
| 18 |
VECT_VAR_DECL(expected_max_sh1,uint,8,16) [] = { 0x7f, 0x7f, 0x7f, 0x7f, |
| 19 |
0x7f, 0x7f, 0x7f, 0x7f, |
| 20 |
0xff, 0xff, 0xff, 0xff, |
| 21 |
0xff, 0xff, 0xff, 0xff }; |
| 22 |
VECT_VAR_DECL(expected_max_sh1,uint,16,8) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff, |
| 23 |
0xffff, 0xffff, 0xffff, 0xffff }; |
| 24 |
VECT_VAR_DECL(expected_max_sh1,uint,32,4) [] = { 0x7fffffff, 0x7fffffff, |
| 25 |
0xffffffff, 0xffffffff }; |
| 26 |
|
| 27 |
/* Expected results. */ |
| 28 |
VECT_VAR_DECL(expected,uint,8,16) [] = { 0x12, 0x12, 0x12, 0x12, |
| 29 |
0x12, 0x12, 0x12, 0x12, |
| 30 |
0x48, 0x48, 0x48, 0x48, |
| 31 |
0x48, 0x48, 0x48, 0x48 }; |
| 32 |
VECT_VAR_DECL(expected,uint,16,8) [] = { 0x4321, 0x4321, 0x4321, 0x4321, |
| 33 |
0x0, 0x0, 0x0, 0x0 }; |
| 34 |
VECT_VAR_DECL(expected,uint,32,4) [] = { 0xdeadbeef, 0xdeadbeef, |
| 35 |
0xdeadbe, 0xdeadbe }; |
| 36 |
|
| 37 |
#define INSN vqshrun_high_n |
| 38 |
#define TEST_MSG "VQSHRUN_HIGH_N" |
| 39 |
|
| 40 |
#define FNNAME1(NAME) void exec_ ## NAME (void) |
| 41 |
#define FNNAME(NAME) FNNAME1(NAME) |
| 42 |
|
| 43 |
FNNAME (INSN) |
| 44 |
{ |
| 45 |
/* Basic test: y=vqshrun_high_n(x,v), then store the result. */ |
| 46 |
#define TEST_VQSHRUN_HIGH_N2(INSN, T1, T2, W, W2, N, N2, V) \ |
| 47 |
VECT_VAR(vector_res, uint, W2, N2) = \ |
| 48 |
INSN##_##T2##W(VECT_VAR(vector1,uint, W2, N), \ |
| 49 |
VECT_VAR(vector2, T1, W, N), V); \ |
| 50 |
vst1q_u##W2(VECT_VAR(result, uint, W2, N2), \ |
| 51 |
VECT_VAR(vector_res, uint, W2, N2)); \ |
| 52 |
|
| 53 |
/* Two auxliary macros are necessary to expand INSN */ |
| 54 |
#define TEST_VQSHRUN_HIGH_N1(INSN, T1, T2, W, W2, N, N2, V) \ |
| 55 |
TEST_VQSHRUN_HIGH_N2(INSN, T1, T2, W, W2, N, N2, V) |
| 56 |
|
| 57 |
#define TEST_VQSHRUN_HIGH_N(T1, T2, W, W2, N, N2, V) \ |
| 58 |
TEST_VQSHRUN_HIGH_N1(INSN, T1, T2, W, W2, N, N2, V) |
| 59 |
|
| 60 |
|
| 61 |
DECL_VARIABLE(vector1, uint, 8, 8); |
| 62 |
DECL_VARIABLE(vector1, uint, 16, 4); |
| 63 |
DECL_VARIABLE(vector1, uint, 32, 2); |
| 64 |
|
| 65 |
/* vector is twice as large as vector_res. */ |
| 66 |
DECL_VARIABLE(vector2, int, 16, 8); |
| 67 |
DECL_VARIABLE(vector2, int, 32, 4); |
| 68 |
DECL_VARIABLE(vector2, int, 64, 2); |
| 69 |
|
| 70 |
DECL_VARIABLE(vector_res, uint, 8, 16); |
| 71 |
DECL_VARIABLE(vector_res, uint, 16, 8); |
| 72 |
DECL_VARIABLE(vector_res, uint, 32, 4); |
| 73 |
|
| 74 |
clean_results (); |
| 75 |
|
| 76 |
/* Fill input vector with negative values, to check saturation on |
| 77 |
limits. */ |
| 78 |
VDUP(vector1, , uint, u, 8, 8, -2); |
| 79 |
VDUP(vector1, , uint, u, 16, 4, -3); |
| 80 |
VDUP(vector1, , uint, u, 32, 2, -4); |
| 81 |
|
| 82 |
VDUP(vector2, q, int, s, 16, 8, -2); |
| 83 |
VDUP(vector2, q, int, s, 32, 4, -3); |
| 84 |
VDUP(vector2, q, int, s, 64, 2, -4); |
| 85 |
|
| 86 |
/* Choose shift amount arbitrarily. */ |
| 87 |
#define CMT " (negative input)" |
| 88 |
TEST_VQSHRUN_HIGH_N(int, s, 16, 8, 8, 16, 3); |
| 89 |
TEST_VQSHRUN_HIGH_N(int, s, 32, 16, 4, 8, 4); |
| 90 |
TEST_VQSHRUN_HIGH_N(int, s, 64, 32, 2, 4, 2); |
| 91 |
|
| 92 |
CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_neg, CMT); |
| 93 |
CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_neg, CMT); |
| 94 |
CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_neg, CMT); |
| 95 |
|
| 96 |
|
| 97 |
/* Fill input vector with max value, to check saturation on |
| 98 |
limits. */ |
| 99 |
VDUP(vector1, , uint, u, 8, 8, 0x7F); |
| 100 |
VDUP(vector1, , uint, u, 16, 4, 0x7FFF); |
| 101 |
VDUP(vector1, , uint, u, 32, 2, 0x7FFFFFFFLL); |
| 102 |
|
| 103 |
VDUP(vector2, q, int, s, 16, 8, 0x7FFF); |
| 104 |
VDUP(vector2, q, int, s, 32, 4, 0x7FFFFFFF); |
| 105 |
VDUP(vector2, q, int, s, 64, 2, 0x7FFFFFFFFFFFFFFFLL); |
| 106 |
|
| 107 |
#undef CMT |
| 108 |
#define CMT " (check cumulative saturation)" |
| 109 |
TEST_VQSHRUN_HIGH_N(int, s, 16, 8, 8, 16, 1); |
| 110 |
TEST_VQSHRUN_HIGH_N(int, s, 32, 16, 4, 8, 1); |
| 111 |
TEST_VQSHRUN_HIGH_N(int, s, 64, 32, 2, 4, 1); |
| 112 |
|
| 113 |
CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_max_sh1, CMT); |
| 114 |
CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_max_sh1, CMT); |
| 115 |
CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_max_sh1, CMT); |
| 116 |
|
| 117 |
|
| 118 |
/* Fill input vector with positive values, to check normal case. */ |
| 119 |
VDUP(vector1, , uint, u, 8, 8, 0x12); |
| 120 |
VDUP(vector1, , uint, u, 16, 4, 0x4321); |
| 121 |
VDUP(vector1, , uint, u, 32, 2, 0xDEADBEEF); |
| 122 |
|
| 123 |
VDUP(vector2, q, int, s, 16, 8, 0x1234); |
| 124 |
VDUP(vector2, q, int, s, 32, 4, 0x87654321); |
| 125 |
VDUP(vector2, q, int, s, 64, 2, 0xDEADBEEF); |
| 126 |
|
| 127 |
#undef CMT |
| 128 |
#define CMT "" |
| 129 |
TEST_VQSHRUN_HIGH_N(int, s, 16, 8, 8, 16, 6); |
| 130 |
TEST_VQSHRUN_HIGH_N(int, s, 32, 16, 4, 8, 7); |
| 131 |
TEST_VQSHRUN_HIGH_N(int, s, 64, 32, 2, 4, 8); |
| 132 |
|
| 133 |
CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected, CMT); |
| 134 |
CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected, CMT); |
| 135 |
CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, CMT); |
| 136 |
} |
| 137 |
|
| 138 |
int main (void) |
| 139 |
{ |
| 140 |
exec_vqshrun_high_n (); |
| 141 |
return 0; |
| 142 |
} |