xref: /aosp_15_r20/external/XNNPACK/src/qs8-igemm/gen/2x16c2-minmax-rndnu-neon-mull-ld1r.c (revision 4bdc94577ba0e567308109d787f7fec7b531ce36)
1 // Auto-generated file. Do not edit!
2 //   Template: src/qs8-igemm/c2-neon-mull-dup.c.in
3 //   Generator: tools/xngen
4 //
5 // Copyright 2021 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 
12 #include <arm_neon.h>
13 
14 #include <xnnpack/gemm.h>
15 #include <xnnpack/math.h>
16 
xnn_qs8_igemm_minmax_rndnu_ukernel_2x16c2__neon_mull_ld1r(size_t mr,size_t nc,size_t kc,size_t ks,const int8_t ** restrict a,const void * restrict w,int8_t * restrict c,size_t cm_stride,size_t cn_stride,size_t a_offset,const int8_t * zero,const union xnn_qs8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_qs8_igemm_minmax_rndnu_ukernel_2x16c2__neon_mull_ld1r(
18     size_t mr,
19     size_t nc,
20     size_t kc,
21     size_t ks,
22     const int8_t** restrict a,
23     const void* restrict w,
24     int8_t* restrict c,
25     size_t cm_stride,
26     size_t cn_stride,
27     size_t a_offset,
28     const int8_t* zero,
29     const union xnn_qs8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
30 {
31   assert(mr != 0);
32   assert(mr <= 2);
33   assert(nc != 0);
34   assert(kc != 0);
35   assert(ks != 0);
36   assert(ks % (2 * sizeof(void*)) == 0);
37   assert(a_offset % sizeof(int8_t) == 0);
38   assert(a != NULL);
39   assert(w != NULL);
40   assert(c != NULL);
41 
42   kc = round_up_po2(kc, 2 * sizeof(int8_t));
43   int8_t* c0 = c;
44   int8_t* c1 = (int8_t*) ((uintptr_t) c0 + cm_stride);
45   if XNN_UNPREDICTABLE(mr != 2) {
46     c1 = c0;
47   }
48 
49   do {
50     int32x4_t vacc0x0123 = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t));
51     int32x4_t vacc0x4567 = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t));
52     int32x4_t vacc0x89AB = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t));
53     int32x4_t vacc0xCDEF = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t));
54     int32x4_t vacc1x0123 = vacc0x0123;
55     int32x4_t vacc1x4567 = vacc0x4567;
56     int32x4_t vacc1x89AB = vacc0x89AB;
57     int32x4_t vacc1xCDEF = vacc0xCDEF;
58 
59     size_t p = ks;
60     do {
61       const int8_t* restrict a0 = a[0];
62       if XNN_UNPREDICTABLE(a0 != zero) {
63         a0 = (const int8_t*) ((uintptr_t) a0 + a_offset);
64       }
65       const int8_t* restrict a1 = a[1];
66       if XNN_UNPREDICTABLE(a1 != zero) {
67         a1 = (const int8_t*) ((uintptr_t) a1 + a_offset);
68       }
69       a += 2;
70 
71       size_t k = kc;
72 
73 
74       while (k >= 8 * sizeof(int8_t)) {
75         const int16x4_t va00 = vld1_dup_s16((const void*)a0);
76         const int16x4_t va01 = vld1_dup_s16((const void*)(a0 + 2));
77         const int16x4_t va02 = vld1_dup_s16((const void*)(a0 + 4));
78         const int16x4_t va03 = vld1_dup_s16((const void*)(a0 + 6)); a0 += 8;
79         const int16x4_t va10 = vld1_dup_s16((const void*)a1);
80         const int16x4_t va11 = vld1_dup_s16((const void*)(a1 + 2));
81         const int16x4_t va12 = vld1_dup_s16((const void*)(a1 + 4));
82         const int16x4_t va13 = vld1_dup_s16((const void*)(a1 + 6)); a1 += 8;
83 
84         const int8x8_t vb0123c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
85         const int8x8_t vb4567c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
86         const int8x8_t vb89ABc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
87         const int8x8_t vbCDEFc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
88         const int8x8_t vb0123c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
89         const int8x8_t vb4567c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
90         const int8x8_t vb89ABc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
91         const int8x8_t vbCDEFc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
92         const int8x8_t vb0123c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
93         const int8x8_t vb4567c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
94         const int8x8_t vb89ABc2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
95         const int8x8_t vbCDEFc2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
96         const int8x8_t vb0123c3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
97         const int8x8_t vb4567c3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
98         const int8x8_t vb89ABc3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
99         const int8x8_t vbCDEFc3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
100 
101         const int8x8_t va0c0 = vreinterpret_s8_s16(va00);
102         const int8x8_t va1c0 = vreinterpret_s8_s16(va10);
103 
104         const int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0, va0c0);
105         const int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0, va1c0);
106         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
107         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
108         const int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0, va0c0);
109         const int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0, va1c0);
110         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
111         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
112         const int16x8_t vprod0x89ABc0 = vmull_s8(vb89ABc0, va0c0);
113         const int16x8_t vprod1x89ABc0 = vmull_s8(vb89ABc0, va1c0);
114         vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc0);
115         vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc0);
116         const int16x8_t vprod0xCDEFc0 = vmull_s8(vbCDEFc0, va0c0);
117         const int16x8_t vprod1xCDEFc0 = vmull_s8(vbCDEFc0, va1c0);
118         vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc0);
119         vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc0);
120         const int8x8_t va0c1 = vreinterpret_s8_s16(va01);
121         const int8x8_t va1c1 = vreinterpret_s8_s16(va11);
122 
123         const int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1, va0c1);
124         const int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1, va1c1);
125         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
126         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
127         const int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1, va0c1);
128         const int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1, va1c1);
129         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
130         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
131         const int16x8_t vprod0x89ABc1 = vmull_s8(vb89ABc1, va0c1);
132         const int16x8_t vprod1x89ABc1 = vmull_s8(vb89ABc1, va1c1);
133         vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc1);
134         vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc1);
135         const int16x8_t vprod0xCDEFc1 = vmull_s8(vbCDEFc1, va0c1);
136         const int16x8_t vprod1xCDEFc1 = vmull_s8(vbCDEFc1, va1c1);
137         vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc1);
138         vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc1);
139         const int8x8_t va0c2 = vreinterpret_s8_s16(va02);
140         const int8x8_t va1c2 = vreinterpret_s8_s16(va12);
141 
142         const int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2, va0c2);
143         const int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2, va1c2);
144         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
145         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
146         const int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2, va0c2);
147         const int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2, va1c2);
148         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
149         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
150         const int16x8_t vprod0x89ABc2 = vmull_s8(vb89ABc2, va0c2);
151         const int16x8_t vprod1x89ABc2 = vmull_s8(vb89ABc2, va1c2);
152         vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc2);
153         vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc2);
154         const int16x8_t vprod0xCDEFc2 = vmull_s8(vbCDEFc2, va0c2);
155         const int16x8_t vprod1xCDEFc2 = vmull_s8(vbCDEFc2, va1c2);
156         vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc2);
157         vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc2);
158         const int8x8_t va0c3 = vreinterpret_s8_s16(va03);
159         const int8x8_t va1c3 = vreinterpret_s8_s16(va13);
160 
161         const int16x8_t vprod0x0123c3 = vmull_s8(vb0123c3, va0c3);
162         const int16x8_t vprod1x0123c3 = vmull_s8(vb0123c3, va1c3);
163         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c3);
164         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c3);
165         const int16x8_t vprod0x4567c3 = vmull_s8(vb4567c3, va0c3);
166         const int16x8_t vprod1x4567c3 = vmull_s8(vb4567c3, va1c3);
167         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c3);
168         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c3);
169         const int16x8_t vprod0x89ABc3 = vmull_s8(vb89ABc3, va0c3);
170         const int16x8_t vprod1x89ABc3 = vmull_s8(vb89ABc3, va1c3);
171         vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc3);
172         vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc3);
173         const int16x8_t vprod0xCDEFc3 = vmull_s8(vbCDEFc3, va0c3);
174         const int16x8_t vprod1xCDEFc3 = vmull_s8(vbCDEFc3, va1c3);
175         vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc3);
176         vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc3);
177 
178         k -= 8 * sizeof(int8_t);
179       }
180 
181       if XNN_UNLIKELY(k != 0) {
182         const int8x8_t va0 = vld1_s8(a0); a0 = (const int8_t*) ((uintptr_t) a0 + k);
183         const int8x8_t va1 = vld1_s8(a1); a1 = (const int8_t*) ((uintptr_t) a1 + k);
184 
185         const int8x8_t vb0123c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
186         const int8x8_t vb4567c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
187         const int8x8_t vb89ABc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
188         const int8x8_t vbCDEFc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
189 
190         const int8x8_t va0c0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 0));
191         const int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0, va0c0);
192         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
193         const int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0, va0c0);
194         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
195         const int16x8_t vprod0x89ABc0 = vmull_s8(vb89ABc0, va0c0);
196         vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc0);
197         const int16x8_t vprod0xCDEFc0 = vmull_s8(vbCDEFc0, va0c0);
198         vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc0);
199         const int8x8_t va1c0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 0));
200         const int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0, va1c0);
201         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
202         const int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0, va1c0);
203         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
204         const int16x8_t vprod1x89ABc0 = vmull_s8(vb89ABc0, va1c0);
205         vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc0);
206         const int16x8_t vprod1xCDEFc0 = vmull_s8(vbCDEFc0, va1c0);
207         vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc0);
208 
209         if (k > 2 * sizeof(int8_t)) {
210           const int8x8_t vb0123c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
211           const int8x8_t vb4567c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
212           const int8x8_t vb89ABc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
213           const int8x8_t vbCDEFc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
214 
215           const int8x8_t va0c1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 1));
216           const int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1, va0c1);
217           vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
218           const int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1, va0c1);
219           vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
220           const int16x8_t vprod0x89ABc1 = vmull_s8(vb89ABc1, va0c1);
221           vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc1);
222           const int16x8_t vprod0xCDEFc1 = vmull_s8(vbCDEFc1, va0c1);
223           vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc1);
224           const int8x8_t va1c1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 1));
225           const int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1, va1c1);
226           vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
227           const int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1, va1c1);
228           vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
229           const int16x8_t vprod1x89ABc1 = vmull_s8(vb89ABc1, va1c1);
230           vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc1);
231           const int16x8_t vprod1xCDEFc1 = vmull_s8(vbCDEFc1, va1c1);
232           vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc1);
233 
234           if (k > 4 * sizeof(int8_t)) {
235             const int8x8_t vb0123c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
236             const int8x8_t vb4567c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
237             const int8x8_t vb89ABc2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
238             const int8x8_t vbCDEFc2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
239 
240             const int8x8_t va0c2 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 2));
241             const int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2, va0c2);
242             vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
243             const int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2, va0c2);
244             vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
245             const int16x8_t vprod0x89ABc2 = vmull_s8(vb89ABc2, va0c2);
246             vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc2);
247             const int16x8_t vprod0xCDEFc2 = vmull_s8(vbCDEFc2, va0c2);
248             vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc2);
249             const int8x8_t va1c2 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 2));
250             const int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2, va1c2);
251             vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
252             const int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2, va1c2);
253             vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
254             const int16x8_t vprod1x89ABc2 = vmull_s8(vb89ABc2, va1c2);
255             vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc2);
256             const int16x8_t vprod1xCDEFc2 = vmull_s8(vbCDEFc2, va1c2);
257             vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc2);
258           }
259         }
260       }
261       p -= 2 * sizeof(void*);
262     } while (p != 0);
263 
264     const int32x4_t vright_pre_shift = vld1q_dup_s32(&params->rndnu_neon.right_pre_shift);
265     const int32x4_t vmultiplier = vld1q_dup_s32(&params->rndnu_neon.multiplier);
266     const int32x4_t vright_post_shift = vld1q_dup_s32(&params->rndnu_neon.right_post_shift);
267 
268     vacc0x0123 = vqshlq_s32(vacc0x0123, vright_pre_shift);
269     vacc0x4567 = vqshlq_s32(vacc0x4567, vright_pre_shift);
270     vacc0x89AB = vqshlq_s32(vacc0x89AB, vright_pre_shift);
271     vacc0xCDEF = vqshlq_s32(vacc0xCDEF, vright_pre_shift);
272     vacc1x0123 = vqshlq_s32(vacc1x0123, vright_pre_shift);
273     vacc1x4567 = vqshlq_s32(vacc1x4567, vright_pre_shift);
274     vacc1x89AB = vqshlq_s32(vacc1x89AB, vright_pre_shift);
275     vacc1xCDEF = vqshlq_s32(vacc1xCDEF, vright_pre_shift);
276 
277     vacc0x0123 = vqdmulhq_s32(vacc0x0123, vmultiplier);
278     vacc0x4567 = vqdmulhq_s32(vacc0x4567, vmultiplier);
279     vacc0x89AB = vqdmulhq_s32(vacc0x89AB, vmultiplier);
280     vacc0xCDEF = vqdmulhq_s32(vacc0xCDEF, vmultiplier);
281     vacc1x0123 = vqdmulhq_s32(vacc1x0123, vmultiplier);
282     vacc1x4567 = vqdmulhq_s32(vacc1x4567, vmultiplier);
283     vacc1x89AB = vqdmulhq_s32(vacc1x89AB, vmultiplier);
284     vacc1xCDEF = vqdmulhq_s32(vacc1xCDEF, vmultiplier);
285 
286     vacc0x0123 = vrshlq_s32(vacc0x0123, vright_post_shift);
287     vacc0x4567 = vrshlq_s32(vacc0x4567, vright_post_shift);
288     vacc0x89AB = vrshlq_s32(vacc0x89AB, vright_post_shift);
289     vacc0xCDEF = vrshlq_s32(vacc0xCDEF, vright_post_shift);
290     vacc1x0123 = vrshlq_s32(vacc1x0123, vright_post_shift);
291     vacc1x4567 = vrshlq_s32(vacc1x4567, vright_post_shift);
292     vacc1x89AB = vrshlq_s32(vacc1x89AB, vright_post_shift);
293     vacc1xCDEF = vrshlq_s32(vacc1xCDEF, vright_post_shift);
294 
295     const int16x8_t voutput_zero_point = vld1q_dup_s16(&params->rndnu_neon.output_zero_point);
296 #if XNN_ARCH_ARM64
297     int16x8_t vacc0x01234567 = vqmovn_high_s32(vqmovn_s32(vacc0x0123), vacc0x4567);
298     int16x8_t vacc0x89ABCDEF = vqmovn_high_s32(vqmovn_s32(vacc0x89AB), vacc0xCDEF);
299     int16x8_t vacc1x01234567 = vqmovn_high_s32(vqmovn_s32(vacc1x0123), vacc1x4567);
300     int16x8_t vacc1x89ABCDEF = vqmovn_high_s32(vqmovn_s32(vacc1x89AB), vacc1xCDEF);
301 
302     vacc0x01234567 = vqaddq_s16(vacc0x01234567, voutput_zero_point);
303     vacc0x89ABCDEF = vqaddq_s16(vacc0x89ABCDEF, voutput_zero_point);
304     vacc1x01234567 = vqaddq_s16(vacc1x01234567, voutput_zero_point);
305     vacc1x89ABCDEF = vqaddq_s16(vacc1x89ABCDEF, voutput_zero_point);
306 
307     int8x16_t vout0x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc0x01234567), vacc0x89ABCDEF);
308     int8x16_t vout1x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc1x01234567), vacc1x89ABCDEF);
309 #else
310     int16x8_t vacc0x01234567 = vcombine_s16(vqmovn_s32(vacc0x0123), vqmovn_s32(vacc0x4567));
311     int16x8_t vacc0x89ABCDEF = vcombine_s16(vqmovn_s32(vacc0x89AB), vqmovn_s32(vacc0xCDEF));
312     int16x8_t vacc1x01234567 = vcombine_s16(vqmovn_s32(vacc1x0123), vqmovn_s32(vacc1x4567));
313     int16x8_t vacc1x89ABCDEF = vcombine_s16(vqmovn_s32(vacc1x89AB), vqmovn_s32(vacc1xCDEF));
314 
315     vacc0x01234567 = vqaddq_s16(vacc0x01234567, voutput_zero_point);
316     vacc0x89ABCDEF = vqaddq_s16(vacc0x89ABCDEF, voutput_zero_point);
317     vacc1x01234567 = vqaddq_s16(vacc1x01234567, voutput_zero_point);
318     vacc1x89ABCDEF = vqaddq_s16(vacc1x89ABCDEF, voutput_zero_point);
319 
320     int8x16_t vout0x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc0x01234567), vqmovn_s16(vacc0x89ABCDEF));
321     int8x16_t vout1x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc1x01234567), vqmovn_s16(vacc1x89ABCDEF));
322 #endif
323 
324     const int8x16_t voutput_min = vld1q_dup_s8(&params->rndnu_neon.output_min);
325     vout0x0123456789ABCDEF = vmaxq_s8(vout0x0123456789ABCDEF, voutput_min);
326     vout1x0123456789ABCDEF = vmaxq_s8(vout1x0123456789ABCDEF, voutput_min);
327 
328     const int8x16_t voutput_max = vld1q_dup_s8(&params->rndnu_neon.output_max);
329     vout0x0123456789ABCDEF = vminq_s8(vout0x0123456789ABCDEF, voutput_max);
330     vout1x0123456789ABCDEF = vminq_s8(vout1x0123456789ABCDEF, voutput_max);
331 
332     if (nc >= 16) {
333       vst1q_s8(c1 + 0, vout1x0123456789ABCDEF);
334       vst1q_s8(c0 + 0, vout0x0123456789ABCDEF);
335 
336       c1 = (int8_t*) ((uintptr_t) c1 + cn_stride);
337       c0 = (int8_t*) ((uintptr_t) c0 + cn_stride);
338 
339       a = (const int8_t**restrict) ((uintptr_t) a - ks);
340 
341       nc -= 16;
342     } else {
343       int8x16_t vout0x01234567_1x01234567 = vcombine_s8(vget_low_s8(vout0x0123456789ABCDEF), vget_low_s8(vout1x0123456789ABCDEF));
344       if (nc & 8) {
345         vst1_s8(c1, vget_high_s8(vout0x01234567_1x01234567)); c1 += 8;
346         vst1_s8(c0, vget_low_s8(vout0x01234567_1x01234567)); c0 += 8;
347         vout0x01234567_1x01234567 = vcombine_s8(vget_high_s8(vout0x0123456789ABCDEF), vget_high_s8(vout1x0123456789ABCDEF));
348       }
349       if (nc & 4) {
350         vst1q_lane_u32((void*) c1, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 2); c1 += 4;
351         vst1q_lane_u32((void*) c0, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 0); c0 += 4;
352         vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 4);
353       }
354       if (nc & 2) {
355         vst1q_lane_u16((void*) c1, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 4); c1 += 2;
356         vst1q_lane_u16((void*) c0, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 0); c0 += 2;
357         vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 2);
358       }
359       if (nc & 1) {
360         vst1q_lane_s8(c1, vout0x01234567_1x01234567, 8);
361         vst1q_lane_s8(c0, vout0x01234567_1x01234567, 0);
362       }
363 
364       nc = 0;
365     }
366   } while (nc != 0);
367 }
368