xref: /aosp_15_r20/external/XNNPACK/src/s16-vlshift/gen/scalar-x4.c (revision 4bdc94577ba0e567308109d787f7fec7b531ce36)
1 // Auto-generated file. Do not edit!
2 //   Template: src/s16-vlshift/scalar.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 <xnnpack/math.h>
15 #include <xnnpack/vlshift.h>
16 
17 
xnn_s16_vlshift_ukernel__scalar_x4(size_t batch,const int16_t * input,int16_t * output,uint32_t shift)18 void xnn_s16_vlshift_ukernel__scalar_x4(
19     size_t batch,
20     const int16_t* input,
21     int16_t* output,
22     uint32_t shift)
23 {
24   assert(batch != 0);
25   assert(input != NULL);
26   assert(output != NULL);
27   assert(shift < 16);
28 
29   for (; batch >= 4; batch -= 4) {
30     const uint16_t vi0 = (uint16_t) input[0];
31     const uint16_t vi1 = (uint16_t) input[1];
32     const uint16_t vi2 = (uint16_t) input[2];
33     const uint16_t vi3 = (uint16_t) input[3];
34     input += 4;
35 
36     const uint16_t vout0 = vi0 << shift;
37     const uint16_t vout1 = vi1 << shift;
38     const uint16_t vout2 = vi2 << shift;
39     const uint16_t vout3 = vi3 << shift;
40 
41     output[0] = (int16_t) vout0;
42     output[1] = (int16_t) vout1;
43     output[2] = (int16_t) vout2;
44     output[3] = (int16_t) vout3;
45     output += 4;
46   }
47  if XNN_UNLIKELY(batch != 0) {
48    do {
49      const uint16_t vi = (uint16_t) *input++;
50 
51      const uint16_t vout = vi << shift;
52 
53      *output++ = (int16_t) vout;
54    } while (--batch != 0);
55  }
56 }
57