1 /* { dg-do run } */
2 /* { dg-options "-O3 -fno-inline" } */
3 
4 #include <arm_neon.h>
5 
6 extern void abort (void);
7 
8 #define VARIANTS(VARIANT)	\
9 VARIANT (uint8, , 8, _u8, 5)	\
10 VARIANT (uint16, , 4, _u16, 3)	\
11 VARIANT (uint32, , 2, _u32, 1)	\
12 VARIANT (uint64, , 1, _u64, 0)	\
13 VARIANT (int8, , 8, _s8, 3)	\
14 VARIANT (int16, , 4, _s16, 2)	\
15 VARIANT (int32, , 2, _s32, 0)	\
16 VARIANT (int64, , 1, _s64, 0)	\
17 VARIANT (poly8, , 8, _p8, 7)	\
18 VARIANT (poly16, , 4, _p16, 2)	\
19 VARIANT (float16, , 4, _f16, 3)	\
20 VARIANT (float32, , 2, _f32, 1)	\
21 VARIANT (float64, , 1, _f64, 0)	\
22 VARIANT (uint8, q, 16, _u8, 13)	\
23 VARIANT (uint16, q, 8, _u16, 5)	\
24 VARIANT (uint32, q, 4, _u32, 1)	\
25 VARIANT (uint64, q, 2, _u64, 0)	\
26 VARIANT (int8, q, 16, _s8, 15)	\
27 VARIANT (int16, q, 8, _s16, 3)	\
28 VARIANT (int32, q, 4, _s32, 1)	\
29 VARIANT (int64, q, 2, _s64, 1)	\
30 VARIANT (poly8, q, 16, _p8, 7)	\
31 VARIANT (poly16, q, 8, _p16, 4)	\
32 VARIANT (float16, q, 8, _f16, 3)\
33 VARIANT (float32, q, 4, _f32, 2)\
34 VARIANT (float64, q, 2, _f64, 1)
35 
36 #define TESTMETH(BASE, Q, ELTS, SUFFIX, LANE)			\
37 __attribute__((noinline)) BASE##x##ELTS##_t			\
38 wrap_vld1##Q##_lane##SUFFIX (const BASE##_t *load,		\
39 			     BASE##x##ELTS##_t vec)		\
40 { return vld1##Q##_lane##SUFFIX (load, vec, LANE); }		\
41 int								\
42 test_vld1##Q##_lane##SUFFIX (const BASE##_t *data,		\
43 			     const BASE##_t *overwrite)		\
44 {								\
45   BASE##_t out[ELTS];						\
46   int j;							\
47   BASE##x##ELTS##_t in = vld1##Q##SUFFIX (data);		\
48   in = wrap_vld1##Q##_lane##SUFFIX (overwrite, in);		\
49   vst1##Q##SUFFIX (out, in);					\
50     for (j = 0; j < ELTS; j++)					\
51       if (out[j] != (j == LANE ? *overwrite : data[j]))		\
52         return 1;						\
53   return 0;							\
54 }
55 
56 
VARIANTS(TESTMETH)57 VARIANTS (TESTMETH)
58 
59 #define CHECK(BASE, Q, ELTS, SUFFIX, LANE)			\
60   if (test_vld1##Q##_lane##SUFFIX ((const BASE##_t *)orig_data,	\
61 				   & BASE##_data) != 0)	\
62     abort ();
63 
64 int
65 main (int argc, char **argv)
66 {
67   /* Original data for all vector formats.  */
68   uint64_t orig_data[2] = {0x1234567890abcdefULL, 0x13579bdf02468aceULL};
69 
70   /* Data with which vld1_lane will overwrite one element of previous.  */
71   uint8_t uint8_data = 7;
72   uint16_t uint16_data = 257;
73   uint32_t uint32_data = 65537;
74   uint64_t uint64_data = 0xdeadbeefcafebabeULL;
75   int8_t int8_data = -1;
76   int16_t int16_data = -259;
77   int32_t int32_data = -987654321;
78   int64_t int64_data = 0x1234567890abcdefLL;
79   poly8_t poly8_data = 13;
80   poly16_t poly16_data = 11111;
81   float16_t float16_data = 8.75;
82   float32_t float32_data = 3.14159;
83   float64_t float64_data = 1.010010001;
84 
85   VARIANTS (CHECK);
86   return 0;
87 }
88