1 // Auto-generated file. Do not edit!
2 // Template: src/s16-vlshift/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/math.h>
17 #include <xnnpack/vlshift.h>
18
19
xnn_s16_vlshift_ukernel__neon_x24(size_t batch,const int16_t * input,int16_t * output,uint32_t shift)20 void xnn_s16_vlshift_ukernel__neon_x24(
21 size_t batch,
22 const int16_t* input,
23 int16_t* output,
24 uint32_t shift)
25 {
26 assert(batch > 0);
27 assert(input != NULL);
28 assert(output != NULL);
29 assert(shift < 16);
30
31 const int16x8_t vshift = vdupq_n_s16((int16_t) shift);
32
33 for (; batch >= 24; batch -= 24) {
34 const int16x8_t vi0 = vld1q_s16(input); input += 8;
35 const int16x8_t vi1 = vld1q_s16(input); input += 8;
36 const int16x8_t vi2 = vld1q_s16(input); input += 8;
37
38 const int16x8_t vout0 = vshlq_s16(vi0, vshift);
39 const int16x8_t vout1 = vshlq_s16(vi1, vshift);
40 const int16x8_t vout2 = vshlq_s16(vi2, vshift);
41
42 vst1q_s16(output, vout0); output += 8;
43 vst1q_s16(output, vout1); output += 8;
44 vst1q_s16(output, vout2); output += 8;
45 }
46
47 // Remainder of full vectors
48 for (; batch >= 8; batch -= 8) {
49 const int16x8_t vi = vld1q_s16(input); input += 8;
50
51 const int16x8_t vout = vshlq_s16(vi, vshift);
52
53 vst1q_s16(output, vout); output += 8;
54 }
55
56 // Remainder of 1 to 7 batch
57 if XNN_UNLIKELY(batch != 0) {
58 const int16x8_t vi = vld1q_s16(input);
59
60 const int16x8_t vout = vshlq_s16(vi, vshift);
61 int16x4_t vout_lo = vget_low_s16(vout);
62
63 if (batch & 4) {
64 vst1_s16(output, vout_lo); output += 4;
65 vout_lo = vget_high_s16(vout);
66 }
67 if (batch & 2) {
68 vst1_lane_u32((void*) output, vreinterpret_u32_s16(vout_lo), 0); output += 2;
69 vout_lo = vext_s16(vout_lo, vout_lo, 2);
70 }
71 if (batch & 1){
72 vst1_lane_s16(output, vout_lo, 0);
73 }
74 }
75 }
76