• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/qs8-gemm/c4-neondot.c.in
3 //   Generator: tools/xngen
4 //
5 // Copyright 2020 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/intrinsics-polyfill.h>
16 #include <xnnpack/math.h>
17 
18 
xnn_qc8_gemm_minmax_fp32_ukernel_4x16c4__neondot(size_t mr,size_t nc,size_t kc,const int8_t * restrict a,size_t a_stride,const void * restrict w,int8_t * restrict c,size_t cm_stride,size_t cn_stride,const union xnn_qc8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])19 void xnn_qc8_gemm_minmax_fp32_ukernel_4x16c4__neondot(
20     size_t mr,
21     size_t nc,
22     size_t kc,
23     const int8_t* restrict a,
24     size_t a_stride,
25     const void* restrict w,
26     int8_t* restrict c,
27     size_t cm_stride,
28     size_t cn_stride,
29     const union xnn_qc8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
30 {
31   assert(mr != 0);
32   assert(mr <= 4);
33   assert(nc != 0);
34   assert(kc != 0);
35   assert(kc % sizeof(int8_t) == 0);
36   assert(a != NULL);
37   assert(w != NULL);
38   assert(c != NULL);
39 
40   kc = round_up_po2(kc, 4 * sizeof(int8_t));
41   const int8_t* a0 = a;
42   int8_t* c0 = c;
43   const int8_t* a1 = (const int8_t*) ((uintptr_t) a0 + a_stride);
44   int8_t* c1 = (int8_t*) ((uintptr_t) c0 + cm_stride);
45   if XNN_UNPREDICTABLE(mr < 2) {
46     a1 = a0;
47     c1 = c0;
48   }
49   const int8_t* a2 = (const int8_t*) ((uintptr_t) a1 + a_stride);
50   int8_t* c2 = (int8_t*) ((uintptr_t) c1 + cm_stride);
51   if XNN_UNPREDICTABLE(mr <= 2) {
52     a2 = a1;
53     c2 = c1;
54   }
55   const int8_t* a3 = (const int8_t*) ((uintptr_t) a2 + a_stride);
56   int8_t* c3 = (int8_t*) ((uintptr_t) c2 + cm_stride);
57   if XNN_UNPREDICTABLE(mr != 4) {
58     a3 = a2;
59     c3 = c2;
60   }
61 
62   // Loop over groups of 16 columns.
63   do {
64     // Initialize accumulators with bias. 16 bias values are loaded from the
65     // weight matrix, at the start of the group of 16 columns.
66     int32x4_t vacc0x0123 = vld1q_s32(w); w = (const void*) ((const int32_t*) w + 4);
67     int32x4_t vacc0x4567 = vld1q_s32(w); w = (const void*) ((const int32_t*) w + 4);
68     int32x4_t vacc0x89AB = vld1q_s32(w); w = (const void*) ((const int32_t*) w + 4);
69     int32x4_t vacc0xCDEF = vld1q_s32(w); w = (const void*) ((const int32_t*) w + 4);
70     int32x4_t vacc1x0123 = vacc0x0123;
71     int32x4_t vacc1x4567 = vacc0x4567;
72     int32x4_t vacc1x89AB = vacc0x89AB;
73     int32x4_t vacc1xCDEF = vacc0xCDEF;
74     int32x4_t vacc2x0123 = vacc0x0123;
75     int32x4_t vacc2x4567 = vacc0x4567;
76     int32x4_t vacc2x89AB = vacc0x89AB;
77     int32x4_t vacc2xCDEF = vacc0xCDEF;
78     int32x4_t vacc3x0123 = vacc0x0123;
79     int32x4_t vacc3x4567 = vacc0x4567;
80     int32x4_t vacc3x89AB = vacc0x89AB;
81     int32x4_t vacc3xCDEF = vacc0xCDEF;
82 
83     // Inner accumulation loop along the 16 columns.
84     size_t k = kc;
85     // 2x partial unrolled loop to load 8 bytes at a time.
86     while (k >= 8 * sizeof(int8_t)) {
87       // Load a 4x8 block of activations.
88       const int8x8_t va0x01234567 = vld1_s8(a0); a0 += 8;
89       const int8x8_t va1x01234567 = vld1_s8(a1); a1 += 8;
90       const int8x8_t va2x01234567 = vld1_s8(a2); a2 += 8;
91       const int8x8_t va3x01234567 = vld1_s8(a3); a3 += 8;
92 
93       // Load a 8x16 block of weights.
94       const int8x16_t vb0123x0123 = vld1q_s8(w); w = (const void*) ((const int8_t*) w + 16);
95       const int8x16_t vb0123x4567 = vld1q_s8(w); w = (const void*) ((const int8_t*) w + 16);
96       const int8x16_t vb0123x89AB = vld1q_s8(w); w = (const void*) ((const int8_t*) w + 16);
97       const int8x16_t vb0123xCDEF = vld1q_s8(w); w = (const void*) ((const int8_t*) w + 16);
98       const int8x16_t vb4567x0123 = vld1q_s8(w); w = (const void*) ((const int8_t*) w + 16);
99       const int8x16_t vb4567x4567 = vld1q_s8(w); w = (const void*) ((const int8_t*) w + 16);
100       const int8x16_t vb4567x89AB = vld1q_s8(w); w = (const void*) ((const int8_t*) w + 16);
101       const int8x16_t vb4567xCDEF = vld1q_s8(w); w = (const void*) ((const int8_t*) w + 16);
102 
103       // Multiply-accumulate: 4x8 * 8x16 --> 4x16.
104       vacc0x0123 = vdotq_lane_s32(vacc0x0123, vb0123x0123, va0x01234567, 0);
105       vacc0x4567 = vdotq_lane_s32(vacc0x4567, vb0123x4567, va0x01234567, 0);
106       vacc0x89AB = vdotq_lane_s32(vacc0x89AB, vb0123x89AB, va0x01234567, 0);
107       vacc0xCDEF = vdotq_lane_s32(vacc0xCDEF, vb0123xCDEF, va0x01234567, 0);
108       vacc1x0123 = vdotq_lane_s32(vacc1x0123, vb0123x0123, va1x01234567, 0);
109       vacc1x4567 = vdotq_lane_s32(vacc1x4567, vb0123x4567, va1x01234567, 0);
110       vacc1x89AB = vdotq_lane_s32(vacc1x89AB, vb0123x89AB, va1x01234567, 0);
111       vacc1xCDEF = vdotq_lane_s32(vacc1xCDEF, vb0123xCDEF, va1x01234567, 0);
112       vacc2x0123 = vdotq_lane_s32(vacc2x0123, vb0123x0123, va2x01234567, 0);
113       vacc2x4567 = vdotq_lane_s32(vacc2x4567, vb0123x4567, va2x01234567, 0);
114       vacc2x89AB = vdotq_lane_s32(vacc2x89AB, vb0123x89AB, va2x01234567, 0);
115       vacc2xCDEF = vdotq_lane_s32(vacc2xCDEF, vb0123xCDEF, va2x01234567, 0);
116       vacc3x0123 = vdotq_lane_s32(vacc3x0123, vb0123x0123, va3x01234567, 0);
117       vacc3x4567 = vdotq_lane_s32(vacc3x4567, vb0123x4567, va3x01234567, 0);
118       vacc3x89AB = vdotq_lane_s32(vacc3x89AB, vb0123x89AB, va3x01234567, 0);
119       vacc3xCDEF = vdotq_lane_s32(vacc3xCDEF, vb0123xCDEF, va3x01234567, 0);
120       vacc0x0123 = vdotq_lane_s32(vacc0x0123, vb4567x0123, va0x01234567, 1);
121       vacc0x4567 = vdotq_lane_s32(vacc0x4567, vb4567x4567, va0x01234567, 1);
122       vacc0x89AB = vdotq_lane_s32(vacc0x89AB, vb4567x89AB, va0x01234567, 1);
123       vacc0xCDEF = vdotq_lane_s32(vacc0xCDEF, vb4567xCDEF, va0x01234567, 1);
124       vacc1x0123 = vdotq_lane_s32(vacc1x0123, vb4567x0123, va1x01234567, 1);
125       vacc1x4567 = vdotq_lane_s32(vacc1x4567, vb4567x4567, va1x01234567, 1);
126       vacc1x89AB = vdotq_lane_s32(vacc1x89AB, vb4567x89AB, va1x01234567, 1);
127       vacc1xCDEF = vdotq_lane_s32(vacc1xCDEF, vb4567xCDEF, va1x01234567, 1);
128       vacc2x0123 = vdotq_lane_s32(vacc2x0123, vb4567x0123, va2x01234567, 1);
129       vacc2x4567 = vdotq_lane_s32(vacc2x4567, vb4567x4567, va2x01234567, 1);
130       vacc2x89AB = vdotq_lane_s32(vacc2x89AB, vb4567x89AB, va2x01234567, 1);
131       vacc2xCDEF = vdotq_lane_s32(vacc2xCDEF, vb4567xCDEF, va2x01234567, 1);
132       vacc3x0123 = vdotq_lane_s32(vacc3x0123, vb4567x0123, va3x01234567, 1);
133       vacc3x4567 = vdotq_lane_s32(vacc3x4567, vb4567x4567, va3x01234567, 1);
134       vacc3x89AB = vdotq_lane_s32(vacc3x89AB, vb4567x89AB, va3x01234567, 1);
135       vacc3xCDEF = vdotq_lane_s32(vacc3xCDEF, vb4567xCDEF, va3x01234567, 1);
136 
137       k -= 8 * sizeof(int8_t);
138     }
139     // Handle up to 4 final positions of `k`
140     if XNN_UNLIKELY(k != 0) {
141       // Load a 4x4 block of activations.
142       const int8x8_t va0x01234567 = vld1_s8(a0); a0 += 4;
143       const int8x8_t va1x01234567 = vld1_s8(a1); a1 += 4;
144       const int8x8_t va2x01234567 = vld1_s8(a2); a2 += 4;
145       const int8x8_t va3x01234567 = vld1_s8(a3); a3 += 4;
146 
147       // Load a 4x16 block of weights.
148       const int8x16_t vb0123x0123 = vld1q_s8(w); w = (const void*) ((const int8_t*) w + 16);
149       const int8x16_t vb0123x4567 = vld1q_s8(w); w = (const void*) ((const int8_t*) w + 16);
150       const int8x16_t vb0123x89AB = vld1q_s8(w); w = (const void*) ((const int8_t*) w + 16);
151       const int8x16_t vb0123xCDEF = vld1q_s8(w); w = (const void*) ((const int8_t*) w + 16);
152 
153       // Multiply-accumulate: 4x4 * 4x16 --> 4x16.
154       vacc0x0123 = vdotq_lane_s32(vacc0x0123, vb0123x0123, va0x01234567, 0);
155       vacc0x4567 = vdotq_lane_s32(vacc0x4567, vb0123x4567, va0x01234567, 0);
156       vacc0x89AB = vdotq_lane_s32(vacc0x89AB, vb0123x89AB, va0x01234567, 0);
157       vacc0xCDEF = vdotq_lane_s32(vacc0xCDEF, vb0123xCDEF, va0x01234567, 0);
158       vacc1x0123 = vdotq_lane_s32(vacc1x0123, vb0123x0123, va1x01234567, 0);
159       vacc1x4567 = vdotq_lane_s32(vacc1x4567, vb0123x4567, va1x01234567, 0);
160       vacc1x89AB = vdotq_lane_s32(vacc1x89AB, vb0123x89AB, va1x01234567, 0);
161       vacc1xCDEF = vdotq_lane_s32(vacc1xCDEF, vb0123xCDEF, va1x01234567, 0);
162       vacc2x0123 = vdotq_lane_s32(vacc2x0123, vb0123x0123, va2x01234567, 0);
163       vacc2x4567 = vdotq_lane_s32(vacc2x4567, vb0123x4567, va2x01234567, 0);
164       vacc2x89AB = vdotq_lane_s32(vacc2x89AB, vb0123x89AB, va2x01234567, 0);
165       vacc2xCDEF = vdotq_lane_s32(vacc2xCDEF, vb0123xCDEF, va2x01234567, 0);
166       vacc3x0123 = vdotq_lane_s32(vacc3x0123, vb0123x0123, va3x01234567, 0);
167       vacc3x4567 = vdotq_lane_s32(vacc3x4567, vb0123x4567, va3x01234567, 0);
168       vacc3x89AB = vdotq_lane_s32(vacc3x89AB, vb0123x89AB, va3x01234567, 0);
169       vacc3xCDEF = vdotq_lane_s32(vacc3xCDEF, vb0123xCDEF, va3x01234567, 0);
170     }
171 
172     float32x4_t vfpacc0x0123 = vcvtq_f32_s32(vacc0x0123);
173     float32x4_t vfpacc0x4567 = vcvtq_f32_s32(vacc0x4567);
174     float32x4_t vfpacc0x89AB = vcvtq_f32_s32(vacc0x89AB);
175     float32x4_t vfpacc0xCDEF = vcvtq_f32_s32(vacc0xCDEF);
176     float32x4_t vfpacc1x0123 = vcvtq_f32_s32(vacc1x0123);
177     float32x4_t vfpacc1x4567 = vcvtq_f32_s32(vacc1x4567);
178     float32x4_t vfpacc1x89AB = vcvtq_f32_s32(vacc1x89AB);
179     float32x4_t vfpacc1xCDEF = vcvtq_f32_s32(vacc1xCDEF);
180     float32x4_t vfpacc2x0123 = vcvtq_f32_s32(vacc2x0123);
181     float32x4_t vfpacc2x4567 = vcvtq_f32_s32(vacc2x4567);
182     float32x4_t vfpacc2x89AB = vcvtq_f32_s32(vacc2x89AB);
183     float32x4_t vfpacc2xCDEF = vcvtq_f32_s32(vacc2xCDEF);
184     float32x4_t vfpacc3x0123 = vcvtq_f32_s32(vacc3x0123);
185     float32x4_t vfpacc3x4567 = vcvtq_f32_s32(vacc3x4567);
186     float32x4_t vfpacc3x89AB = vcvtq_f32_s32(vacc3x89AB);
187     float32x4_t vfpacc3xCDEF = vcvtq_f32_s32(vacc3xCDEF);
188 
189     const float32x4_t vscale0123 = vld1q_f32((const float*) w); w = (const void*) ((const float*) w + 4);
190     vfpacc0x0123 = vmulq_f32(vfpacc0x0123, vscale0123);
191     vfpacc1x0123 = vmulq_f32(vfpacc1x0123, vscale0123);
192     vfpacc2x0123 = vmulq_f32(vfpacc2x0123, vscale0123);
193     vfpacc3x0123 = vmulq_f32(vfpacc3x0123, vscale0123);
194     const float32x4_t vscale4567 = vld1q_f32((const float*) w); w = (const void*) ((const float*) w + 4);
195     vfpacc0x4567 = vmulq_f32(vfpacc0x4567, vscale4567);
196     vfpacc1x4567 = vmulq_f32(vfpacc1x4567, vscale4567);
197     vfpacc2x4567 = vmulq_f32(vfpacc2x4567, vscale4567);
198     vfpacc3x4567 = vmulq_f32(vfpacc3x4567, vscale4567);
199     const float32x4_t vscale89AB = vld1q_f32((const float*) w); w = (const void*) ((const float*) w + 4);
200     vfpacc0x89AB = vmulq_f32(vfpacc0x89AB, vscale89AB);
201     vfpacc1x89AB = vmulq_f32(vfpacc1x89AB, vscale89AB);
202     vfpacc2x89AB = vmulq_f32(vfpacc2x89AB, vscale89AB);
203     vfpacc3x89AB = vmulq_f32(vfpacc3x89AB, vscale89AB);
204     const float32x4_t vscaleCDEF = vld1q_f32((const float*) w); w = (const void*) ((const float*) w + 4);
205     vfpacc0xCDEF = vmulq_f32(vfpacc0xCDEF, vscaleCDEF);
206     vfpacc1xCDEF = vmulq_f32(vfpacc1xCDEF, vscaleCDEF);
207     vfpacc2xCDEF = vmulq_f32(vfpacc2xCDEF, vscaleCDEF);
208     vfpacc3xCDEF = vmulq_f32(vfpacc3xCDEF, vscaleCDEF);
209 
210     vacc0x0123 = vcvtnq_s32_f32(vfpacc0x0123);
211     vacc0x4567 = vcvtnq_s32_f32(vfpacc0x4567);
212     vacc0x89AB = vcvtnq_s32_f32(vfpacc0x89AB);
213     vacc0xCDEF = vcvtnq_s32_f32(vfpacc0xCDEF);
214     vacc1x0123 = vcvtnq_s32_f32(vfpacc1x0123);
215     vacc1x4567 = vcvtnq_s32_f32(vfpacc1x4567);
216     vacc1x89AB = vcvtnq_s32_f32(vfpacc1x89AB);
217     vacc1xCDEF = vcvtnq_s32_f32(vfpacc1xCDEF);
218     vacc2x0123 = vcvtnq_s32_f32(vfpacc2x0123);
219     vacc2x4567 = vcvtnq_s32_f32(vfpacc2x4567);
220     vacc2x89AB = vcvtnq_s32_f32(vfpacc2x89AB);
221     vacc2xCDEF = vcvtnq_s32_f32(vfpacc2xCDEF);
222     vacc3x0123 = vcvtnq_s32_f32(vfpacc3x0123);
223     vacc3x4567 = vcvtnq_s32_f32(vfpacc3x4567);
224     vacc3x89AB = vcvtnq_s32_f32(vfpacc3x89AB);
225     vacc3xCDEF = vcvtnq_s32_f32(vfpacc3xCDEF);
226 
227     const int16x8_t voutput_zero_point = vld1q_dup_s16(&params->fp32_neonv8.output_zero_point);
228 #if XNN_ARCH_ARM64
229     const int16x8_t vacc0x01234567 = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc0x0123), vacc0x4567), voutput_zero_point);
230     const int16x8_t vacc0x89ABCDEF = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc0x89AB), vacc0xCDEF), voutput_zero_point);
231     const int16x8_t vacc1x01234567 = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc1x0123), vacc1x4567), voutput_zero_point);
232     const int16x8_t vacc1x89ABCDEF = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc1x89AB), vacc1xCDEF), voutput_zero_point);
233     const int16x8_t vacc2x01234567 = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc2x0123), vacc2x4567), voutput_zero_point);
234     const int16x8_t vacc2x89ABCDEF = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc2x89AB), vacc2xCDEF), voutput_zero_point);
235     const int16x8_t vacc3x01234567 = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc3x0123), vacc3x4567), voutput_zero_point);
236     const int16x8_t vacc3x89ABCDEF = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc3x89AB), vacc3xCDEF), voutput_zero_point);
237 
238     int8x16_t vout0x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc0x01234567), vacc0x89ABCDEF);
239     int8x16_t vout1x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc1x01234567), vacc1x89ABCDEF);
240     int8x16_t vout2x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc2x01234567), vacc2x89ABCDEF);
241     int8x16_t vout3x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc3x01234567), vacc3x89ABCDEF);
242 #else
243     const int16x8_t vacc0x01234567 = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc0x0123), vqmovn_s32(vacc0x4567)), voutput_zero_point);
244     const int16x8_t vacc0x89ABCDEF = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc0x89AB), vqmovn_s32(vacc0xCDEF)), voutput_zero_point);
245     const int16x8_t vacc1x01234567 = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc1x0123), vqmovn_s32(vacc1x4567)), voutput_zero_point);
246     const int16x8_t vacc1x89ABCDEF = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc1x89AB), vqmovn_s32(vacc1xCDEF)), voutput_zero_point);
247     const int16x8_t vacc2x01234567 = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc2x0123), vqmovn_s32(vacc2x4567)), voutput_zero_point);
248     const int16x8_t vacc2x89ABCDEF = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc2x89AB), vqmovn_s32(vacc2xCDEF)), voutput_zero_point);
249     const int16x8_t vacc3x01234567 = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc3x0123), vqmovn_s32(vacc3x4567)), voutput_zero_point);
250     const int16x8_t vacc3x89ABCDEF = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc3x89AB), vqmovn_s32(vacc3xCDEF)), voutput_zero_point);
251 
252     int8x16_t vout0x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc0x01234567), vqmovn_s16(vacc0x89ABCDEF));
253     int8x16_t vout1x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc1x01234567), vqmovn_s16(vacc1x89ABCDEF));
254     int8x16_t vout2x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc2x01234567), vqmovn_s16(vacc2x89ABCDEF));
255     int8x16_t vout3x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc3x01234567), vqmovn_s16(vacc3x89ABCDEF));
256 #endif
257     const int8x16_t voutput_min = vld1q_dup_s8(&params->fp32_neonv8.output_min);
258     const int8x16_t voutput_max = vld1q_dup_s8(&params->fp32_neonv8.output_max);
259 
260     vout0x0123456789ABCDEF = vmaxq_s8(vout0x0123456789ABCDEF, voutput_min);
261     vout1x0123456789ABCDEF = vmaxq_s8(vout1x0123456789ABCDEF, voutput_min);
262     vout2x0123456789ABCDEF = vmaxq_s8(vout2x0123456789ABCDEF, voutput_min);
263     vout3x0123456789ABCDEF = vmaxq_s8(vout3x0123456789ABCDEF, voutput_min);
264 
265     vout0x0123456789ABCDEF = vminq_s8(vout0x0123456789ABCDEF, voutput_max);
266     vout1x0123456789ABCDEF = vminq_s8(vout1x0123456789ABCDEF, voutput_max);
267     vout2x0123456789ABCDEF = vminq_s8(vout2x0123456789ABCDEF, voutput_max);
268     vout3x0123456789ABCDEF = vminq_s8(vout3x0123456789ABCDEF, voutput_max);
269 
270     if (nc >= 16) {
271       // Main case where there the 16 columns fit in the destination.
272       vst1q_s8(c0 + 0, vout0x0123456789ABCDEF);
273       vst1q_s8(c1 + 0, vout1x0123456789ABCDEF);
274       vst1q_s8(c2 + 0, vout2x0123456789ABCDEF);
275       vst1q_s8(c3 + 0, vout3x0123456789ABCDEF);
276 
277       // Advance to the next 16 columns.
278       c0 = (int8_t*) ((uintptr_t) c0 + cn_stride);
279       c1 = (int8_t*) ((uintptr_t) c1 + cn_stride);
280       c2 = (int8_t*) ((uintptr_t) c2 + cn_stride);
281       c3 = (int8_t*) ((uintptr_t) c3 + cn_stride);
282 
283       a0 = (const int8_t*) ((uintptr_t) a0 - kc);
284       a1 = (const int8_t*) ((uintptr_t) a1 - kc);
285       a2 = (const int8_t*) ((uintptr_t) a2 - kc);
286       a3 = (const int8_t*) ((uintptr_t) a3 - kc);
287 
288       nc -= 16;
289     } else {
290       // Final case where not all of the 16 columns fit in the destination.
291       int8x16_t vout0x01234567_1x01234567 = vcombine_s8(vget_low_s8(vout0x0123456789ABCDEF), vget_low_s8(vout1x0123456789ABCDEF));
292       int8x16_t vout2x01234567_3x01234567 = vcombine_s8(vget_low_s8(vout2x0123456789ABCDEF), vget_low_s8(vout3x0123456789ABCDEF));
293       if (nc & 8) {
294         vst1_s8(c0, vget_low_s8(vout0x01234567_1x01234567)); c0 += 8;
295         vst1_s8(c1, vget_high_s8(vout0x01234567_1x01234567)); c1 += 8;
296         vst1_s8(c2, vget_low_s8(vout2x01234567_3x01234567)); c2 += 8;
297         vst1_s8(c3, vget_high_s8(vout2x01234567_3x01234567)); c3 += 8;
298         vout0x01234567_1x01234567 = vcombine_s8(vget_high_s8(vout0x0123456789ABCDEF), vget_high_s8(vout1x0123456789ABCDEF));
299         vout2x01234567_3x01234567 = vcombine_s8(vget_high_s8(vout2x0123456789ABCDEF), vget_high_s8(vout3x0123456789ABCDEF));
300       }
301       if (nc & 4) {
302         vst1q_lane_u32((void*) c0, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 0); c0 += 4;
303         vst1q_lane_u32((void*) c1, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 2); c1 += 4;
304         vst1q_lane_u32((void*) c2, vreinterpretq_u32_s8(vout2x01234567_3x01234567), 0); c2 += 4;
305         vst1q_lane_u32((void*) c3, vreinterpretq_u32_s8(vout2x01234567_3x01234567), 2); c3 += 4;
306         vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 4);
307         vout2x01234567_3x01234567 = vextq_s8(vout2x01234567_3x01234567, vout2x01234567_3x01234567, 4);
308       }
309       if (nc & 2) {
310         vst1q_lane_u16((void*) c0, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 0); c0 += 2;
311         vst1q_lane_u16((void*) c1, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 4); c1 += 2;
312         vst1q_lane_u16((void*) c2, vreinterpretq_u16_s8(vout2x01234567_3x01234567), 0); c2 += 2;
313         vst1q_lane_u16((void*) c3, vreinterpretq_u16_s8(vout2x01234567_3x01234567), 4); c3 += 2;
314         vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 2);
315         vout2x01234567_3x01234567 = vextq_s8(vout2x01234567_3x01234567, vout2x01234567_3x01234567, 2);
316       }
317       if (nc & 1) {
318         vst1q_lane_s8(c0, vout0x01234567_1x01234567, 0);
319         vst1q_lane_s8(c1, vout0x01234567_1x01234567, 8);
320         vst1q_lane_s8(c2, vout2x01234567_3x01234567, 0);
321         vst1q_lane_s8(c3, vout2x01234567_3x01234567, 8);
322       }
323 
324       nc = 0;
325     }
326   } while (nc != 0);
327 }
328