1 // Auto-generated file. Do not edit!
2 // Template: src/cs16-vsquareabs/neon.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2022 Google LLC
6 //
7 // This source code is licensed under the BSD-style license found in the
8 // LICENSE file in the root directory of this source tree.
9
10 #include <assert.h>
11 #include <stddef.h>
12 #include <stdint.h>
13
14 #include <arm_neon.h>
15
16 #include <xnnpack/vsquareabs.h>
17
18
xnn_cs16_vsquareabs_ukernel__neon_mlal_ld128_x4(size_t batch,const int16_t * input,uint32_t * output)19 void xnn_cs16_vsquareabs_ukernel__neon_mlal_ld128_x4(
20 size_t batch,
21 const int16_t* input,
22 uint32_t* output) {
23
24 assert(batch != 0);
25 assert(input != NULL);
26 assert(output != NULL);
27
28
29 // Remainder of full vectors
30 for (; batch >= 4; batch -= 4) {
31 const int16x4x2_t vi = vld2_s16(input); input += 8;
32
33 int32x4_t vacc = vmull_s16(vi.val[0], vi.val[0]);
34
35 vacc = vmlal_s16(vacc, vi.val[1], vi.val[1]);
36
37 vst1q_u32(output, vreinterpretq_u32_s32(vacc)); output += 4;
38 }
39
40 // Remainder of 1 to 3 elements
41 if XNN_UNLIKELY(batch != 0) {
42 const int16x4x2_t vi = vld2_s16(input);
43
44 int32x4_t vacc = vmull_s16(vi.val[0], vi.val[0]);
45 vacc = vmlal_s16(vacc, vi.val[1], vi.val[1]);
46
47 uint32x2_t vacc_lo = vreinterpret_u32_s32(vget_low_s32(vacc));
48 if (batch & 2) {
49 vst1_u32(output, vacc_lo); output += 2;
50 vacc_lo = vreinterpret_u32_s32(vget_high_s32(vacc));
51 }
52 if (batch & 1) {
53 vst1_lane_u32(output, vacc_lo, 0);
54 }
55 }
56 }
57