xref: /aosp_15_r20/external/XNNPACK/src/s16-vlshift/gen/scalar-x2.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_x2(size_t batch,const int16_t * input,int16_t * output,uint32_t shift)18 void xnn_s16_vlshift_ukernel__scalar_x2(
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 >= 2; batch -= 2) {
30     const uint16_t vi0 = (uint16_t) input[0];
31     const uint16_t vi1 = (uint16_t) input[1];
32     input += 2;
33 
34     const uint16_t vout0 = vi0 << shift;
35     const uint16_t vout1 = vi1 << shift;
36 
37     output[0] = (int16_t) vout0;
38     output[1] = (int16_t) vout1;
39     output += 2;
40   }
41  if XNN_UNLIKELY(batch != 0) {
42    do {
43      const uint16_t vi = (uint16_t) *input++;
44 
45      const uint16_t vout = vi << shift;
46 
47      *output++ = (int16_t) vout;
48    } while (--batch != 0);
49  }
50 }
51