xref: /aosp_15_r20/external/XNNPACK/src/s16-vlshift/gen/neon-x8.c (revision 4bdc94577ba0e567308109d787f7fec7b531ce36)
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_x8(size_t batch,const int16_t * input,int16_t * output,uint32_t shift)20 void xnn_s16_vlshift_ukernel__neon_x8(
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 
34   // Remainder of full vectors
35   for (; batch >= 8; batch -= 8) {
36     const int16x8_t vi = vld1q_s16(input); input += 8;
37 
38     const int16x8_t vout = vshlq_s16(vi, vshift);
39 
40     vst1q_s16(output, vout); output += 8;
41   }
42 
43   // Remainder of 1 to 7 batch
44   if XNN_UNLIKELY(batch != 0) {
45     const int16x8_t vi = vld1q_s16(input);
46 
47     const int16x8_t vout = vshlq_s16(vi, vshift);
48     int16x4_t vout_lo = vget_low_s16(vout);
49 
50     if (batch & 4) {
51       vst1_s16(output, vout_lo); output += 4;
52       vout_lo = vget_high_s16(vout);
53     }
54     if (batch & 2) {
55       vst1_lane_u32((void*) output, vreinterpret_u32_s16(vout_lo), 0); output += 2;
56       vout_lo = vext_s16(vout_lo, vout_lo, 2);
57     }
58     if (batch & 1){
59       vst1_lane_s16(output, vout_lo, 0);
60     }
61   }
62 }
63