1 // Copyright 2019 Google LLC
2 //
3 // This source code is licensed under the BSD-style license found in the
4 // LICENSE file in the root directory of this source tree.
5
6 #include <assert.h>
7
8 #include <arm_neon.h>
9
10 #include <xnnpack/zip.h>
11
12
xnn_x32_zip_x3_ukernel__neon(size_t n,const uint32_t * input,uint32_t * output)13 void xnn_x32_zip_x3_ukernel__neon(
14 size_t n,
15 const uint32_t* input,
16 uint32_t* output)
17 {
18 assert(n != 0);
19 assert(n % 4 == 0);
20
21 const uint32_t* x = input;
22 const uint32_t* y = (const uint32_t*) ((uintptr_t) x + n);
23 const uint32_t* z = (const uint32_t*) ((uintptr_t) y + n);
24 uint32_t* o = output;
25
26 while (n >= 16) {
27 uint32x4x3_t vxyz;
28 vxyz.val[0] = vld1q_u32(x); x += 4;
29 vxyz.val[1] = vld1q_u32(y); y += 4;
30 vxyz.val[2] = vld1q_u32(z); z += 4;
31 vst3q_u32(o, vxyz); o += 12;
32 n -= 16;
33 }
34 if XNN_UNLIKELY(n != 0) {
35 if (n & 8) {
36 uint32x2x3_t vxyz;
37 vxyz.val[0] = vld1_u32(x); x += 2;
38 vxyz.val[1] = vld1_u32(y); y += 2;
39 vxyz.val[2] = vld1_u32(z); z += 2;
40 vst3_u32(o, vxyz); o += 6;
41 }
42 if (n & 4) {
43 uint32x2_t vxy = vld1_dup_u32(x);
44 const uint32x2_t vz = vld1_dup_u32(z);
45 vxy = vld1_lane_u32(y, vxy, 1);
46 vst1_u32(o, vxy); o += 2;
47 vst1_lane_u32(o, vz, 0);
48 }
49 }
50 }
51