| 1 |
/* This file contains tests for the vreinterpret *p128 intrinsics. */ |
| 2 |
|
| 3 |
/* { dg-require-effective-target arm_crypto_ok { target { arm*-*-* } } } */ |
| 4 |
/* { dg-add-options arm_crypto } */ |
| 5 |
/* { dg-additional-options "-march=armv8-a+crypto" { target { aarch64*-*-* } } }*/ |
| 6 |
|
| 7 |
#include <arm_neon.h> |
| 8 |
#include "arm-neon-ref.h" |
| 9 |
#include "compute-ref-data.h" |
| 10 |
|
| 11 |
/* Expected results: vreinterpretq_p128_*. */ |
| 12 |
VECT_VAR_DECL(vreint_expected_q_p128_s8,poly,64,2) [] = { 0xf7f6f5f4f3f2f1f0, |
| 13 |
0xfffefdfcfbfaf9f8 }; |
| 14 |
VECT_VAR_DECL(vreint_expected_q_p128_s16,poly,64,2) [] = { 0xfff3fff2fff1fff0, |
| 15 |
0xfff7fff6fff5fff4 }; |
| 16 |
VECT_VAR_DECL(vreint_expected_q_p128_s32,poly,64,2) [] = { 0xfffffff1fffffff0, |
| 17 |
0xfffffff3fffffff2 }; |
| 18 |
VECT_VAR_DECL(vreint_expected_q_p128_s64,poly,64,2) [] = { 0xfffffffffffffff0, |
| 19 |
0xfffffffffffffff1 }; |
| 20 |
VECT_VAR_DECL(vreint_expected_q_p128_u8,poly,64,2) [] = { 0xf7f6f5f4f3f2f1f0, |
| 21 |
0xfffefdfcfbfaf9f8 }; |
| 22 |
VECT_VAR_DECL(vreint_expected_q_p128_u16,poly,64,2) [] = { 0xfff3fff2fff1fff0, |
| 23 |
0xfff7fff6fff5fff4 }; |
| 24 |
VECT_VAR_DECL(vreint_expected_q_p128_u32,poly,64,2) [] = { 0xfffffff1fffffff0, |
| 25 |
0xfffffff3fffffff2 }; |
| 26 |
VECT_VAR_DECL(vreint_expected_q_p128_u64,poly,64,2) [] = { 0xfffffffffffffff0, |
| 27 |
0xfffffffffffffff1 }; |
| 28 |
VECT_VAR_DECL(vreint_expected_q_p128_p8,poly,64,2) [] = { 0xf7f6f5f4f3f2f1f0, |
| 29 |
0xfffefdfcfbfaf9f8 }; |
| 30 |
VECT_VAR_DECL(vreint_expected_q_p128_p16,poly,64,2) [] = { 0xfff3fff2fff1fff0, |
| 31 |
0xfff7fff6fff5fff4 }; |
| 32 |
VECT_VAR_DECL(vreint_expected_q_p128_f32,poly,64,2) [] = { 0xc1700000c1800000, |
| 33 |
0xc1500000c1600000 }; |
| 34 |
VECT_VAR_DECL(vreint_expected_q_p128_f16,poly,64,2) [] = { 0xca80cb00cb80cc00, |
| 35 |
0xc880c900c980ca00 }; |
| 36 |
#ifdef __aarch64__ |
| 37 |
VECT_VAR_DECL(vreint_expected_q_p128_f64,poly,64,2) [] = { 0xc030000000000000, |
| 38 |
0xc02e000000000000 }; |
| 39 |
#endif |
| 40 |
|
| 41 |
/* Expected results: vreinterpretq_*_p128. */ |
| 42 |
VECT_VAR_DECL(vreint_expected_q_s8_p128,int,8,16) [] = { 0xf0, 0xff, 0xff, 0xff, |
| 43 |
0xff, 0xff, 0xff, 0xff, |
| 44 |
0xf1, 0xff, 0xff, 0xff, |
| 45 |
0xff, 0xff, 0xff, 0xff }; |
| 46 |
VECT_VAR_DECL(vreint_expected_q_s16_p128,int,16,8) [] = { 0xfff0, 0xffff, |
| 47 |
0xffff, 0xffff, |
| 48 |
0xfff1, 0xffff, |
| 49 |
0xffff, 0xffff }; |
| 50 |
VECT_VAR_DECL(vreint_expected_q_s32_p128,int,32,4) [] = { 0xfffffff0, 0xffffffff, |
| 51 |
0xfffffff1, 0xffffffff }; |
| 52 |
VECT_VAR_DECL(vreint_expected_q_s64_p128,int,64,2) [] = { 0xfffffffffffffff0, |
| 53 |
0xfffffffffffffff1 }; |
| 54 |
VECT_VAR_DECL(vreint_expected_q_u8_p128,uint,8,16) [] = { 0xf0, 0xff, 0xff, 0xff, |
| 55 |
0xff, 0xff, 0xff, 0xff, |
| 56 |
0xf1, 0xff, 0xff, 0xff, |
| 57 |
0xff, 0xff, 0xff, 0xff }; |
| 58 |
VECT_VAR_DECL(vreint_expected_q_u16_p128,uint,16,8) [] = { 0xfff0, 0xffff, |
| 59 |
0xffff, 0xffff, |
| 60 |
0xfff1, 0xffff, |
| 61 |
0xffff, 0xffff }; |
| 62 |
VECT_VAR_DECL(vreint_expected_q_u32_p128,uint,32,4) [] = { 0xfffffff0, 0xffffffff, |
| 63 |
0xfffffff1, 0xffffffff }; |
| 64 |
VECT_VAR_DECL(vreint_expected_q_u64_p128,uint,64,2) [] = { 0xfffffffffffffff0, |
| 65 |
0xfffffffffffffff1 }; |
| 66 |
VECT_VAR_DECL(vreint_expected_q_p8_p128,poly,8,16) [] = { 0xf0, 0xff, 0xff, 0xff, |
| 67 |
0xff, 0xff, 0xff, 0xff, |
| 68 |
0xf1, 0xff, 0xff, 0xff, |
| 69 |
0xff, 0xff, 0xff, 0xff }; |
| 70 |
VECT_VAR_DECL(vreint_expected_q_p16_p128,poly,16,8) [] = { 0xfff0, 0xffff, |
| 71 |
0xffff, 0xffff, |
| 72 |
0xfff1, 0xffff, |
| 73 |
0xffff, 0xffff }; |
| 74 |
VECT_VAR_DECL(vreint_expected_q_p64_p128,uint,64,2) [] = { 0xfffffffffffffff0, |
| 75 |
0xfffffffffffffff1 }; |
| 76 |
VECT_VAR_DECL(vreint_expected_q_f32_p128,hfloat,32,4) [] = { 0xfffffff0, 0xffffffff, |
| 77 |
0xfffffff1, 0xffffffff }; |
| 78 |
VECT_VAR_DECL(vreint_expected_q_f16_p128,hfloat,16,8) [] = { 0xfff0, 0xffff, |
| 79 |
0xffff, 0xffff, |
| 80 |
0xfff1, 0xffff, |
| 81 |
0xffff, 0xffff }; |
| 82 |
#ifdef __aarch64__ |
| 83 |
VECT_VAR_DECL(vreint_expected_q_f64_p128,hfloat,64,2) [] = { 0xfffffffffffffff0, |
| 84 |
0xfffffffffffffff1 }; |
| 85 |
#endif |
| 86 |
|
| 87 |
int main (void) |
| 88 |
{ |
| 89 |
DECL_VARIABLE_128BITS_VARIANTS(vreint_vector); |
| 90 |
DECL_VARIABLE_128BITS_VARIANTS(vreint_vector_res); |
| 91 |
|
| 92 |
clean_results (); |
| 93 |
|
| 94 |
TEST_MACRO_128BITS_VARIANTS_2_5(VLOAD, vreint_vector, buffer); |
| 95 |
VLOAD(vreint_vector, buffer, q, poly, p, 64, 2); |
| 96 |
#if defined (__ARM_FP16_FORMAT_IEEE) || defined (__ARM_FP16_FORMAT_ALTERNATIVE) |
| 97 |
VLOAD(vreint_vector, buffer, q, float, f, 16, 8); |
| 98 |
#endif |
| 99 |
VLOAD(vreint_vector, buffer, q, float, f, 32, 4); |
| 100 |
|
| 101 |
#ifdef __aarch64__ |
| 102 |
VLOAD(vreint_vector, buffer, q, float, f, 64, 2); |
| 103 |
#endif |
| 104 |
|
| 105 |
/* vreinterpretq_p128_* tests. */ |
| 106 |
#undef TEST_MSG |
| 107 |
#define TEST_MSG "VREINTERPRETQ_P128_*" |
| 108 |
|
| 109 |
/* Since there is no way to store a poly128_t value, convert to |
| 110 |
poly64x2_t before storing. This means that we are not able to |
| 111 |
test vreinterpretq_p128* alone, and that errors in |
| 112 |
vreinterpretq_p64_p128 could compensate for errors in |
| 113 |
vreinterpretq_p128*. */ |
| 114 |
#define TEST_VREINTERPRET128(Q, T1, T2, W, N, TS1, TS2, WS, NS, EXPECTED) \ |
| 115 |
VECT_VAR(vreint_vector_res, poly, 64, 2) = vreinterpretq_p64_p128( \ |
| 116 |
vreinterpret##Q##_##T2##W##_##TS2##WS(VECT_VAR(vreint_vector, TS1, WS, NS))); \ |
| 117 |
vst1##Q##_##T2##64(VECT_VAR(result, poly, 64, 2), \ |
| 118 |
VECT_VAR(vreint_vector_res, poly, 64, 2)); \ |
| 119 |
CHECK_POLY(TEST_MSG, T1, 64, 2, PRIx##64, EXPECTED, ""); |
| 120 |
|
| 121 |
TEST_VREINTERPRET128(q, poly, p, 128, 1, int, s, 8, 16, vreint_expected_q_p128_s8); |
| 122 |
TEST_VREINTERPRET128(q, poly, p, 128, 1, int, s, 16, 8, vreint_expected_q_p128_s16); |
| 123 |
TEST_VREINTERPRET128(q, poly, p, 128, 1, int, s, 32, 4, vreint_expected_q_p128_s32); |
| 124 |
TEST_VREINTERPRET128(q, poly, p, 128, 1, int, s, 64, 2, vreint_expected_q_p128_s64); |
| 125 |
TEST_VREINTERPRET128(q, poly, p, 128, 1, uint, u, 8, 16, vreint_expected_q_p128_u8); |
| 126 |
TEST_VREINTERPRET128(q, poly, p, 128, 1, uint, u, 16, 8, vreint_expected_q_p128_u16); |
| 127 |
TEST_VREINTERPRET128(q, poly, p, 128, 1, uint, u, 32, 4, vreint_expected_q_p128_u32); |
| 128 |
TEST_VREINTERPRET128(q, poly, p, 128, 1, uint, u, 64, 2, vreint_expected_q_p128_u64); |
| 129 |
TEST_VREINTERPRET128(q, poly, p, 128, 1, poly, p, 8, 16, vreint_expected_q_p128_p8); |
| 130 |
TEST_VREINTERPRET128(q, poly, p, 128, 1, poly, p, 16, 8, vreint_expected_q_p128_p16); |
| 131 |
#if defined (__ARM_FP16_FORMAT_IEEE) || defined (__ARM_FP16_FORMAT_ALTERNATIVE) |
| 132 |
TEST_VREINTERPRET128(q, poly, p, 128, 1, float, f, 16, 8, vreint_expected_q_p128_f16); |
| 133 |
#endif |
| 134 |
TEST_VREINTERPRET128(q, poly, p, 128, 1, float, f, 32, 4, vreint_expected_q_p128_f32); |
| 135 |
|
| 136 |
#ifdef __aarch64__ |
| 137 |
TEST_VREINTERPRET128(q, poly, p, 128, 1, float, f, 64, 2, vreint_expected_q_p128_f64); |
| 138 |
#endif |
| 139 |
|
| 140 |
/* vreinterpretq_*_p128 tests. */ |
| 141 |
#undef TEST_MSG |
| 142 |
#define TEST_MSG "VREINTERPRETQ_*_P128" |
| 143 |
|
| 144 |
/* Since there is no way to load a poly128_t value, load a |
| 145 |
poly64x2_t and convert it to poly128_t. This means that we are |
| 146 |
not able to test vreinterpretq_*_p128 alone, and that errors in |
| 147 |
vreinterpretq_p128_p64 could compensate for errors in |
| 148 |
vreinterpretq_*_p128*. */ |
| 149 |
#define TEST_VREINTERPRET_FROM_P128(Q, T1, T2, W, N, TS1, TS2, WS, NS, EXPECTED) \ |
| 150 |
VECT_VAR(vreint_vector_res, T1, W, N) = \ |
| 151 |
vreinterpret##Q##_##T2##W##_##TS2##WS( \ |
| 152 |
vreinterpretq_p128_p64(VECT_VAR(vreint_vector, TS1, 64, 2))); \ |
| 153 |
vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \ |
| 154 |
VECT_VAR(vreint_vector_res, T1, W, N)); \ |
| 155 |
CHECK(TEST_MSG, T1, W, N, PRIx##W, EXPECTED, ""); |
| 156 |
|
| 157 |
#define TEST_VREINTERPRET_FP_FROM_P128(Q, T1, T2, W, N, TS1, TS2, WS, NS, EXPECTED) \ |
| 158 |
VECT_VAR(vreint_vector_res, T1, W, N) = \ |
| 159 |
vreinterpret##Q##_##T2##W##_##TS2##WS( \ |
| 160 |
vreinterpretq_p128_p64(VECT_VAR(vreint_vector, TS1, 64, 2))); \ |
| 161 |
vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \ |
| 162 |
VECT_VAR(vreint_vector_res, T1, W, N)); \ |
| 163 |
CHECK_FP(TEST_MSG, T1, W, N, PRIx##W, EXPECTED, ""); |
| 164 |
|
| 165 |
TEST_VREINTERPRET_FROM_P128(q, int, s, 8, 16, poly, p, 128, 1, vreint_expected_q_s8_p128); |
| 166 |
TEST_VREINTERPRET_FROM_P128(q, int, s, 16, 8, poly, p, 128, 1, vreint_expected_q_s16_p128); |
| 167 |
TEST_VREINTERPRET_FROM_P128(q, int, s, 32, 4, poly, p, 128, 1, vreint_expected_q_s32_p128); |
| 168 |
TEST_VREINTERPRET_FROM_P128(q, int, s, 64, 2, poly, p, 128, 1, vreint_expected_q_s64_p128); |
| 169 |
TEST_VREINTERPRET_FROM_P128(q, uint, u, 8, 16, poly, p, 128, 1, vreint_expected_q_u8_p128); |
| 170 |
TEST_VREINTERPRET_FROM_P128(q, uint, u, 16, 8, poly, p, 128, 1, vreint_expected_q_u16_p128); |
| 171 |
TEST_VREINTERPRET_FROM_P128(q, uint, u, 32, 4, poly, p, 128, 1, vreint_expected_q_u32_p128); |
| 172 |
TEST_VREINTERPRET_FROM_P128(q, uint, u, 64, 2, poly, p, 128, 1, vreint_expected_q_u64_p128); |
| 173 |
TEST_VREINTERPRET_FROM_P128(q, poly, p, 8, 16, poly, p, 128, 1, vreint_expected_q_p8_p128); |
| 174 |
TEST_VREINTERPRET_FROM_P128(q, poly, p, 16, 8, poly, p, 128, 1, vreint_expected_q_p16_p128); |
| 175 |
#if defined (__ARM_FP16_FORMAT_IEEE) || defined (__ARM_FP16_FORMAT_ALTERNATIVE) |
| 176 |
TEST_VREINTERPRET_FP_FROM_P128(q, float, f, 16, 8, poly, p, 128, 1, vreint_expected_q_f16_p128); |
| 177 |
#endif |
| 178 |
TEST_VREINTERPRET_FP_FROM_P128(q, float, f, 32, 4, poly, p, 128, 1, vreint_expected_q_f32_p128); |
| 179 |
|
| 180 |
#ifdef __aarch64__ |
| 181 |
TEST_VREINTERPRET_FP_FROM_P128(q, float, f, 64, 2, poly, p, 128, 1, vreint_expected_q_f64_p128); |
| 182 |
#endif |
| 183 |
return 0; |
| 184 |
} |