2015-07-03 Christophe Lyon <christophe.lyon@linaro.org>
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / advsimd-intrinsics / vget_lane.c
blob580605072bcce95a4680c14d73cd6ce50aa128c6
1 #include <arm_neon.h>
2 #include "arm-neon-ref.h"
3 #include "compute-ref-data.h"
5 /* Expected results. */
6 int8_t expected_s8 = 0xf7;
7 int16_t expected_s16 = 0xfff3;
8 int32_t expected_s32 = 0xfffffff1;
9 int64_t expected_s64 = 0xfffffffffffffff0;
10 uint8_t expected_u8 = 0xf6;
11 uint16_t expected_u16 = 0xfff2;
12 uint32_t expected_u32 = 0xfffffff1;
13 uint64_t expected_u64 = 0xfffffffffffffff0;
14 poly8_t expected_p8 = 0xf6;
15 poly16_t expected_p16 = 0xfff2;
16 hfloat32_t expected_f32 = 0xc1700000;
18 int8_t expectedq_s8 = 0xff;
19 int16_t expectedq_s16 = 0xfff5;
20 int32_t expectedq_s32 = 0xfffffff3;
21 int64_t expectedq_s64 = 0xfffffffffffffff1;
22 uint8_t expectedq_u8 = 0xfe;
23 uint16_t expectedq_u16 = 0xfff6;
24 uint32_t expectedq_u32 = 0xfffffff2;
25 uint64_t expectedq_u64 = 0xfffffffffffffff1;
26 poly8_t expectedq_p8 = 0xfe;
27 poly16_t expectedq_p16 = 0xfff6;
28 hfloat32_t expectedq_f32 = 0xc1500000;
30 int error_found = 0;
32 #define TEST_MSG "VGET_LANE"
33 void exec_vget_lane (void)
35 /* vec=vget_lane(vec, lane), then store the result. */
36 #define TEST_VGET_LANE(Q, T1, T2, W, N, L) \
37 VAR(var, T1, W) = vget##Q##_lane_##T2##W(VECT_VAR(vector, T1, W, N), L); \
38 if (VAR(var, T1, W) != expected##Q##_##T2##W) { \
39 fprintf(stderr, \
40 "ERROR in %s (%s line %d in result '%s') at type %s " \
41 "got 0x%" PRIx##W " != 0x%" PRIx##W "\n", \
42 TEST_MSG, __FILE__, __LINE__, \
43 STR(expected##Q##_##T2##W), \
44 STR(VECT_NAME(T1, W, N)), \
45 VAR(var, T1, W), \
46 expected##Q##_##T2##W); \
47 error_found = 1; \
50 /* Special variant for floating-point. */
51 union {
52 uint32_t var_int32;
53 float32_t var_float32;
54 } var_int32_float32;
56 #define TEST_VGET_LANE_FP(Q, T1, T2, W, N, L) \
57 VAR(var, T1, W) = vget##Q##_lane_##T2##W(VECT_VAR(vector, T1, W, N), L); \
58 var_int##W##_float##W.var_float##W = VAR(var, T1, W); \
59 if (var_int##W##_float##W.var_int##W != expected##Q##_##T2##W) { \
60 fprintf(stderr, \
61 "ERROR in %s (%s line %d in result '%s') at type %s " \
62 "got 0x%" PRIx##W " != 0x%" PRIx##W "\n", \
63 TEST_MSG, __FILE__, __LINE__, \
64 STR(expected##Q##_##T2##W), \
65 STR(VECT_NAME(T1, W, N)), \
66 var_int##W##_float##W.var_int##W, \
67 expected##Q##_##T2##W); \
68 error_found = 1; \
71 DECL_VARIABLE_ALL_VARIANTS(vector);
73 /* Scalar variables. */
74 VAR_DECL(var, int, 8);
75 VAR_DECL(var, int, 16);
76 VAR_DECL(var, int, 32);
77 VAR_DECL(var, int, 64);
78 VAR_DECL(var, uint, 8);
79 VAR_DECL(var, uint, 16);
80 VAR_DECL(var, uint, 32);
81 VAR_DECL(var, uint, 64);
82 VAR_DECL(var, poly, 8);
83 VAR_DECL(var, poly, 16);
84 VAR_DECL(var, float, 32);
86 /* Initialize input values. */
87 TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector, buffer);
88 VLOAD(vector, buffer, , float, f, 32, 2);
89 VLOAD(vector, buffer, q, float, f, 32, 4);
91 /* Choose lane arbitrarily. */
92 TEST_VGET_LANE(, int, s, 8, 8, 7);
93 TEST_VGET_LANE(, int, s, 16, 4, 3);
94 TEST_VGET_LANE(, int, s, 32, 2, 1);
95 TEST_VGET_LANE(, int, s, 64, 1, 0);
96 TEST_VGET_LANE(, uint, u, 8, 8, 6);
97 TEST_VGET_LANE(, uint, u, 16, 4, 2);
98 TEST_VGET_LANE(, uint, u, 32, 2, 1);
99 TEST_VGET_LANE(, uint, u, 64, 1, 0);
100 TEST_VGET_LANE(, poly, p, 8, 8, 6);
101 TEST_VGET_LANE(, poly, p, 16, 4, 2);
102 TEST_VGET_LANE_FP(, float, f, 32, 2, 1);
104 TEST_VGET_LANE(q, int, s, 8, 16, 15);
105 TEST_VGET_LANE(q, int, s, 16, 8, 5);
106 TEST_VGET_LANE(q, int, s, 32, 4, 3);
107 TEST_VGET_LANE(q, int, s, 64, 2, 1);
108 TEST_VGET_LANE(q, uint, u, 8, 16, 14);
109 TEST_VGET_LANE(q, uint, u, 16, 8, 6);
110 TEST_VGET_LANE(q, uint, u, 32, 4, 2);
111 TEST_VGET_LANE(q, uint, u, 64, 2, 1);
112 TEST_VGET_LANE(q, poly, p, 8, 16, 14);
113 TEST_VGET_LANE(q, poly, p, 16, 8, 6);
114 TEST_VGET_LANE_FP(q, float, f, 32, 4, 3);
117 int main (void)
119 exec_vget_lane ();
121 if (error_found)
122 abort();
124 return 0;