1 // Auto-generated file. Do not edit!
2 // Template: src/qs8-gemm/MRx4c2-sse.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 <emmintrin.h>
13
14 #include <xnnpack/gemm.h>
15 #include <xnnpack/math.h>
16
17
xnn_qs8_gemm_xw_minmax_ukernel_4x4c2__sse2(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_qs8_gemm_xw_params params[restrict XNN_MIN_ELEMENTS (1)])18 void xnn_qs8_gemm_xw_minmax_ukernel_4x4c2__sse2(
19 size_t mr,
20 size_t nc,
21 size_t kc,
22 const int8_t* restrict a,
23 size_t a_stride,
24 const void* restrict w,
25 int8_t* restrict c,
26 size_t cm_stride,
27 size_t cn_stride,
28 const union xnn_qs8_gemm_xw_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_DISABLE_TSAN
29 {
30 assert(mr != 0);
31 assert(mr <= 4);
32 assert(nc != 0);
33 assert(kc != 0);
34 assert(kc % sizeof(int8_t) == 0);
35 assert(a != NULL);
36 assert(w != NULL);
37 assert(c != NULL);
38
39 kc = round_up_po2(kc, 2);
40 const int8_t* a0 = a;
41 int8_t* c0 = c;
42 const int8_t* a1 = (const int8_t*) ((uintptr_t) a0 + a_stride);
43 int8_t* c1 = (int8_t*) ((uintptr_t) c0 + cm_stride);
44 if XNN_UNPREDICTABLE(mr < 2) {
45 a1 = a0;
46 c1 = c0;
47 }
48 const int8_t* a2 = (const int8_t*) ((uintptr_t) a1 + a_stride);
49 int8_t* c2 = (int8_t*) ((uintptr_t) c1 + cm_stride);
50 if XNN_UNPREDICTABLE(mr <= 2) {
51 a2 = a1;
52 c2 = c1;
53 }
54 const int8_t* a3 = (const int8_t*) ((uintptr_t) a2 + a_stride);
55 int8_t* c3 = (int8_t*) ((uintptr_t) c2 + cm_stride);
56 if XNN_UNPREDICTABLE(mr != 4) {
57 a3 = a2;
58 c3 = c2;
59 }
60
61 do {
62 __m128i vacc0x0123 = _mm_loadu_si128((const __m128i*) w);
63 __m128i vacc1x0123 = vacc0x0123;
64 __m128i vacc2x0123 = vacc0x0123;
65 __m128i vacc3x0123 = vacc0x0123;
66 w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t));
67
68 size_t k = kc;
69 while (k >= 8 * sizeof(int8_t)) {
70 const __m128i va0 = _mm_loadl_epi64((const __m128i*) a0);
71 const __m128i vxa0 = _mm_unpacklo_epi8(va0, _mm_cmpgt_epi8(_mm_setzero_si128(), va0));
72 a0 += 8;
73 const __m128i va1 = _mm_loadl_epi64((const __m128i*) a1);
74 const __m128i vxa1 = _mm_unpacklo_epi8(va1, _mm_cmpgt_epi8(_mm_setzero_si128(), va1));
75 a1 += 8;
76 const __m128i va2 = _mm_loadl_epi64((const __m128i*) a2);
77 const __m128i vxa2 = _mm_unpacklo_epi8(va2, _mm_cmpgt_epi8(_mm_setzero_si128(), va2));
78 a2 += 8;
79 const __m128i va3 = _mm_loadl_epi64((const __m128i*) a3);
80 const __m128i vxa3 = _mm_unpacklo_epi8(va3, _mm_cmpgt_epi8(_mm_setzero_si128(), va3));
81 a3 += 8;
82
83 const __m128i vxb0 = _mm_load_si128((const __m128i*) w);
84
85 vacc0x0123 = _mm_add_epi32(vacc0x0123,
86 _mm_madd_epi16(_mm_shuffle_epi32(vxa0, _MM_SHUFFLE(0, 0, 0, 0)), vxb0));
87 vacc1x0123 = _mm_add_epi32(vacc1x0123,
88 _mm_madd_epi16(_mm_shuffle_epi32(vxa1, _MM_SHUFFLE(0, 0, 0, 0)), vxb0));
89 vacc2x0123 = _mm_add_epi32(vacc2x0123,
90 _mm_madd_epi16(_mm_shuffle_epi32(vxa2, _MM_SHUFFLE(0, 0, 0, 0)), vxb0));
91 vacc3x0123 = _mm_add_epi32(vacc3x0123,
92 _mm_madd_epi16(_mm_shuffle_epi32(vxa3, _MM_SHUFFLE(0, 0, 0, 0)), vxb0));
93 const __m128i vxb1 = _mm_load_si128((const __m128i*) ((uintptr_t) w + 8 * sizeof(int16_t)));
94
95 vacc0x0123 = _mm_add_epi32(vacc0x0123,
96 _mm_madd_epi16(_mm_shuffle_epi32(vxa0, _MM_SHUFFLE(1, 1, 1, 1)), vxb1));
97 vacc1x0123 = _mm_add_epi32(vacc1x0123,
98 _mm_madd_epi16(_mm_shuffle_epi32(vxa1, _MM_SHUFFLE(1, 1, 1, 1)), vxb1));
99 vacc2x0123 = _mm_add_epi32(vacc2x0123,
100 _mm_madd_epi16(_mm_shuffle_epi32(vxa2, _MM_SHUFFLE(1, 1, 1, 1)), vxb1));
101 vacc3x0123 = _mm_add_epi32(vacc3x0123,
102 _mm_madd_epi16(_mm_shuffle_epi32(vxa3, _MM_SHUFFLE(1, 1, 1, 1)), vxb1));
103 const __m128i vxb2 = _mm_load_si128((const __m128i*) ((uintptr_t) w + 16 * sizeof(int16_t)));
104
105 vacc0x0123 = _mm_add_epi32(vacc0x0123,
106 _mm_madd_epi16(_mm_shuffle_epi32(vxa0, _MM_SHUFFLE(2, 2, 2, 2)), vxb2));
107 vacc1x0123 = _mm_add_epi32(vacc1x0123,
108 _mm_madd_epi16(_mm_shuffle_epi32(vxa1, _MM_SHUFFLE(2, 2, 2, 2)), vxb2));
109 vacc2x0123 = _mm_add_epi32(vacc2x0123,
110 _mm_madd_epi16(_mm_shuffle_epi32(vxa2, _MM_SHUFFLE(2, 2, 2, 2)), vxb2));
111 vacc3x0123 = _mm_add_epi32(vacc3x0123,
112 _mm_madd_epi16(_mm_shuffle_epi32(vxa3, _MM_SHUFFLE(2, 2, 2, 2)), vxb2));
113 const __m128i vxb3 = _mm_load_si128((const __m128i*) ((uintptr_t) w + 24 * sizeof(int16_t)));
114
115 vacc0x0123 = _mm_add_epi32(vacc0x0123,
116 _mm_madd_epi16(_mm_shuffle_epi32(vxa0, _MM_SHUFFLE(3, 3, 3, 3)), vxb3));
117 vacc1x0123 = _mm_add_epi32(vacc1x0123,
118 _mm_madd_epi16(_mm_shuffle_epi32(vxa1, _MM_SHUFFLE(3, 3, 3, 3)), vxb3));
119 vacc2x0123 = _mm_add_epi32(vacc2x0123,
120 _mm_madd_epi16(_mm_shuffle_epi32(vxa2, _MM_SHUFFLE(3, 3, 3, 3)), vxb3));
121 vacc3x0123 = _mm_add_epi32(vacc3x0123,
122 _mm_madd_epi16(_mm_shuffle_epi32(vxa3, _MM_SHUFFLE(3, 3, 3, 3)), vxb3));
123
124 w = (const void*) ((uintptr_t) w + 32 * sizeof(int16_t));
125 k -= 8 * sizeof(int8_t);
126 }
127 if (k != 0) {
128 const __m128i va0 = _mm_loadl_epi64((const __m128i*) a0);
129 const __m128i vxa0 = _mm_unpacklo_epi8(va0, _mm_cmpgt_epi8(_mm_setzero_si128(), va0));
130 a0 = (const int8_t*) ((uintptr_t) a0 + k);
131 const __m128i va1 = _mm_loadl_epi64((const __m128i*) a1);
132 const __m128i vxa1 = _mm_unpacklo_epi8(va1, _mm_cmpgt_epi8(_mm_setzero_si128(), va1));
133 a1 = (const int8_t*) ((uintptr_t) a1 + k);
134 const __m128i va2 = _mm_loadl_epi64((const __m128i*) a2);
135 const __m128i vxa2 = _mm_unpacklo_epi8(va2, _mm_cmpgt_epi8(_mm_setzero_si128(), va2));
136 a2 = (const int8_t*) ((uintptr_t) a2 + k);
137 const __m128i va3 = _mm_loadl_epi64((const __m128i*) a3);
138 const __m128i vxa3 = _mm_unpacklo_epi8(va3, _mm_cmpgt_epi8(_mm_setzero_si128(), va3));
139 a3 = (const int8_t*) ((uintptr_t) a3 + k);
140
141 const __m128i vxb0 = _mm_load_si128((const __m128i*) w);
142 w = (const void*) ((uintptr_t) w + 8 * sizeof(int16_t));
143
144 vacc0x0123 = _mm_add_epi32(vacc0x0123,
145 _mm_madd_epi16(_mm_shuffle_epi32(vxa0, _MM_SHUFFLE(0, 0, 0, 0)), vxb0));
146 vacc1x0123 = _mm_add_epi32(vacc1x0123,
147 _mm_madd_epi16(_mm_shuffle_epi32(vxa1, _MM_SHUFFLE(0, 0, 0, 0)), vxb0));
148 vacc2x0123 = _mm_add_epi32(vacc2x0123,
149 _mm_madd_epi16(_mm_shuffle_epi32(vxa2, _MM_SHUFFLE(0, 0, 0, 0)), vxb0));
150 vacc3x0123 = _mm_add_epi32(vacc3x0123,
151 _mm_madd_epi16(_mm_shuffle_epi32(vxa3, _MM_SHUFFLE(0, 0, 0, 0)), vxb0));
152
153 if (k > 2 * sizeof(int8_t)) {
154 const __m128i vxb1 = _mm_load_si128((const __m128i*) w);
155 w = (const void*) ((uintptr_t) w + 8 * sizeof(int16_t));
156
157 vacc0x0123 = _mm_add_epi32(vacc0x0123,
158 _mm_madd_epi16(_mm_shuffle_epi32(vxa0, _MM_SHUFFLE(1, 1, 1, 1)), vxb1));
159 vacc1x0123 = _mm_add_epi32(vacc1x0123,
160 _mm_madd_epi16(_mm_shuffle_epi32(vxa1, _MM_SHUFFLE(1, 1, 1, 1)), vxb1));
161 vacc2x0123 = _mm_add_epi32(vacc2x0123,
162 _mm_madd_epi16(_mm_shuffle_epi32(vxa2, _MM_SHUFFLE(1, 1, 1, 1)), vxb1));
163 vacc3x0123 = _mm_add_epi32(vacc3x0123,
164 _mm_madd_epi16(_mm_shuffle_epi32(vxa3, _MM_SHUFFLE(1, 1, 1, 1)), vxb1));
165
166 if (k > 4 * sizeof(int8_t)) {
167 const __m128i vxb2 = _mm_load_si128((const __m128i*) w);
168 w = (const void*) ((uintptr_t) w + 8 * sizeof(int16_t));
169
170 vacc0x0123 = _mm_add_epi32(vacc0x0123,
171 _mm_madd_epi16(_mm_shuffle_epi32(vxa0, _MM_SHUFFLE(2, 2, 2, 2)), vxb2));
172 vacc1x0123 = _mm_add_epi32(vacc1x0123,
173 _mm_madd_epi16(_mm_shuffle_epi32(vxa1, _MM_SHUFFLE(2, 2, 2, 2)), vxb2));
174 vacc2x0123 = _mm_add_epi32(vacc2x0123,
175 _mm_madd_epi16(_mm_shuffle_epi32(vxa2, _MM_SHUFFLE(2, 2, 2, 2)), vxb2));
176 vacc3x0123 = _mm_add_epi32(vacc3x0123,
177 _mm_madd_epi16(_mm_shuffle_epi32(vxa3, _MM_SHUFFLE(2, 2, 2, 2)), vxb2));
178 }
179 }
180 }
181
182 const __m128i vmultiplier = _mm_load_si128((const __m128i*) params->sse2.multiplier);
183 const __m128i vrounding = _mm_load_si128((const __m128i*) params->sse2.rounding);
184
185 const __m128i vnmask0x0123 = _mm_cmpgt_epi32(_mm_setzero_si128(), vacc0x0123);
186 const __m128i vnmask1x0123 = _mm_cmpgt_epi32(_mm_setzero_si128(), vacc1x0123);
187 const __m128i vnmask2x0123 = _mm_cmpgt_epi32(_mm_setzero_si128(), vacc2x0123);
188 const __m128i vnmask3x0123 = _mm_cmpgt_epi32(_mm_setzero_si128(), vacc3x0123);
189
190 const __m128i vabsacc0x0123 = _mm_sub_epi32(_mm_xor_si128(vacc0x0123, vnmask0x0123), vnmask0x0123);
191 const __m128i vabsacc1x0123 = _mm_sub_epi32(_mm_xor_si128(vacc1x0123, vnmask1x0123), vnmask1x0123);
192 const __m128i vabsacc2x0123 = _mm_sub_epi32(_mm_xor_si128(vacc2x0123, vnmask2x0123), vnmask2x0123);
193 const __m128i vabsacc3x0123 = _mm_sub_epi32(_mm_xor_si128(vacc3x0123, vnmask3x0123), vnmask3x0123);
194
195 const __m128i vabsacc0x1133 = _mm_shuffle_epi32(vabsacc0x0123, _MM_SHUFFLE(3, 3, 1, 1));
196 const __m128i vabsacc1x1133 = _mm_shuffle_epi32(vabsacc1x0123, _MM_SHUFFLE(3, 3, 1, 1));
197 const __m128i vabsacc2x1133 = _mm_shuffle_epi32(vabsacc2x0123, _MM_SHUFFLE(3, 3, 1, 1));
198 const __m128i vabsacc3x1133 = _mm_shuffle_epi32(vabsacc3x0123, _MM_SHUFFLE(3, 3, 1, 1));
199
200 const __m128i vabsprod0x02 = _mm_mul_epu32(vabsacc0x0123, vmultiplier);
201 const __m128i vabsprod1x02 = _mm_mul_epu32(vabsacc1x0123, vmultiplier);
202 const __m128i vabsprod2x02 = _mm_mul_epu32(vabsacc2x0123, vmultiplier);
203 const __m128i vabsprod3x02 = _mm_mul_epu32(vabsacc3x0123, vmultiplier);
204
205 const __m128i vnmask0x02 = _mm_shuffle_epi32(vnmask0x0123, _MM_SHUFFLE(2, 2, 0, 0));
206 const __m128i vnmask1x02 = _mm_shuffle_epi32(vnmask1x0123, _MM_SHUFFLE(2, 2, 0, 0));
207 const __m128i vnmask2x02 = _mm_shuffle_epi32(vnmask2x0123, _MM_SHUFFLE(2, 2, 0, 0));
208 const __m128i vnmask3x02 = _mm_shuffle_epi32(vnmask3x0123, _MM_SHUFFLE(2, 2, 0, 0));
209
210 const __m128i vprod0x02 = _mm_sub_epi64(_mm_xor_si128(vabsprod0x02, vnmask0x02), vnmask0x02);
211 const __m128i vprod1x02 = _mm_sub_epi64(_mm_xor_si128(vabsprod1x02, vnmask1x02), vnmask1x02);
212 const __m128i vprod2x02 = _mm_sub_epi64(_mm_xor_si128(vabsprod2x02, vnmask2x02), vnmask2x02);
213 const __m128i vprod3x02 = _mm_sub_epi64(_mm_xor_si128(vabsprod3x02, vnmask3x02), vnmask3x02);
214
215 const __m128i vq31prod0x02 = _mm_srli_epi64(_mm_add_epi64(vprod0x02, vrounding), 31);
216 const __m128i vq31prod1x02 = _mm_srli_epi64(_mm_add_epi64(vprod1x02, vrounding), 31);
217 const __m128i vq31prod2x02 = _mm_srli_epi64(_mm_add_epi64(vprod2x02, vrounding), 31);
218 const __m128i vq31prod3x02 = _mm_srli_epi64(_mm_add_epi64(vprod3x02, vrounding), 31);
219
220 const __m128i vabsprod0x13 = _mm_mul_epu32(vabsacc0x1133, vmultiplier);
221 const __m128i vabsprod1x13 = _mm_mul_epu32(vabsacc1x1133, vmultiplier);
222 const __m128i vabsprod2x13 = _mm_mul_epu32(vabsacc2x1133, vmultiplier);
223 const __m128i vabsprod3x13 = _mm_mul_epu32(vabsacc3x1133, vmultiplier);
224
225 const __m128i vnmask0x13 = _mm_shuffle_epi32(vnmask0x0123, _MM_SHUFFLE(3, 3, 1, 1));
226 const __m128i vnmask1x13 = _mm_shuffle_epi32(vnmask1x0123, _MM_SHUFFLE(3, 3, 1, 1));
227 const __m128i vnmask2x13 = _mm_shuffle_epi32(vnmask2x0123, _MM_SHUFFLE(3, 3, 1, 1));
228 const __m128i vnmask3x13 = _mm_shuffle_epi32(vnmask3x0123, _MM_SHUFFLE(3, 3, 1, 1));
229
230 const __m128i vprod0x13 = _mm_sub_epi64(_mm_xor_si128(vabsprod0x13, vnmask0x13), vnmask0x13);
231 const __m128i vprod1x13 = _mm_sub_epi64(_mm_xor_si128(vabsprod1x13, vnmask1x13), vnmask1x13);
232 const __m128i vprod2x13 = _mm_sub_epi64(_mm_xor_si128(vabsprod2x13, vnmask2x13), vnmask2x13);
233 const __m128i vprod3x13 = _mm_sub_epi64(_mm_xor_si128(vabsprod3x13, vnmask3x13), vnmask3x13);
234
235 const __m128i vq31prod0x13 = _mm_srli_epi64(_mm_add_epi64(vprod0x13, vrounding), 31);
236 const __m128i vq31prod1x13 = _mm_srli_epi64(_mm_add_epi64(vprod1x13, vrounding), 31);
237 const __m128i vq31prod2x13 = _mm_srli_epi64(_mm_add_epi64(vprod2x13, vrounding), 31);
238 const __m128i vq31prod3x13 = _mm_srli_epi64(_mm_add_epi64(vprod3x13, vrounding), 31);
239
240 const __m128i vq31prod0x0213 = _mm_castps_si128(_mm_shuffle_ps(
241 _mm_castsi128_ps(vq31prod0x02), _mm_castsi128_ps(vq31prod0x13), _MM_SHUFFLE(2, 0, 2, 0)));
242 const __m128i vq31prod1x0213 = _mm_castps_si128(_mm_shuffle_ps(
243 _mm_castsi128_ps(vq31prod1x02), _mm_castsi128_ps(vq31prod1x13), _MM_SHUFFLE(2, 0, 2, 0)));
244 const __m128i vq31prod2x0213 = _mm_castps_si128(_mm_shuffle_ps(
245 _mm_castsi128_ps(vq31prod2x02), _mm_castsi128_ps(vq31prod2x13), _MM_SHUFFLE(2, 0, 2, 0)));
246 const __m128i vq31prod3x0213 = _mm_castps_si128(_mm_shuffle_ps(
247 _mm_castsi128_ps(vq31prod3x02), _mm_castsi128_ps(vq31prod3x13), _MM_SHUFFLE(2, 0, 2, 0)));
248
249 const __m128i vq31prod0x0123 = _mm_shuffle_epi32(vq31prod0x0213, _MM_SHUFFLE(3, 1, 2, 0));
250 const __m128i vq31prod1x0123 = _mm_shuffle_epi32(vq31prod1x0213, _MM_SHUFFLE(3, 1, 2, 0));
251 const __m128i vq31prod2x0123 = _mm_shuffle_epi32(vq31prod2x0213, _MM_SHUFFLE(3, 1, 2, 0));
252 const __m128i vq31prod3x0123 = _mm_shuffle_epi32(vq31prod3x0213, _MM_SHUFFLE(3, 1, 2, 0));
253
254 const __m128i vremainder_mask = _mm_load_si128((const __m128i*) params->sse2.remainder_mask);
255 const __m128i vrem0x0123 =
256 _mm_add_epi32(_mm_and_si128(vq31prod0x0123, vremainder_mask), _mm_cmpgt_epi32(_mm_setzero_si128(), vq31prod0x0123));
257 const __m128i vrem1x0123 =
258 _mm_add_epi32(_mm_and_si128(vq31prod1x0123, vremainder_mask), _mm_cmpgt_epi32(_mm_setzero_si128(), vq31prod1x0123));
259 const __m128i vrem2x0123 =
260 _mm_add_epi32(_mm_and_si128(vq31prod2x0123, vremainder_mask), _mm_cmpgt_epi32(_mm_setzero_si128(), vq31prod2x0123));
261 const __m128i vrem3x0123 =
262 _mm_add_epi32(_mm_and_si128(vq31prod3x0123, vremainder_mask), _mm_cmpgt_epi32(_mm_setzero_si128(), vq31prod3x0123));
263
264 const __m128i vremainder_threshold = _mm_load_si128((const __m128i*) params->sse2.remainder_threshold);
265 const __m128i vshift = _mm_load_si128((const __m128i*) params->sse2.shift);
266 vacc0x0123 =
267 _mm_sub_epi32(_mm_sra_epi32(vq31prod0x0123, vshift), _mm_cmpgt_epi32(vrem0x0123, vremainder_threshold));
268 vacc1x0123 =
269 _mm_sub_epi32(_mm_sra_epi32(vq31prod1x0123, vshift), _mm_cmpgt_epi32(vrem1x0123, vremainder_threshold));
270 vacc2x0123 =
271 _mm_sub_epi32(_mm_sra_epi32(vq31prod2x0123, vshift), _mm_cmpgt_epi32(vrem2x0123, vremainder_threshold));
272 vacc3x0123 =
273 _mm_sub_epi32(_mm_sra_epi32(vq31prod3x0123, vshift), _mm_cmpgt_epi32(vrem3x0123, vremainder_threshold));
274
275 const __m128i voutput_zero_point = _mm_load_si128((const __m128i*) params->sse2.output_zero_point);
276 __m128i vacc01x0123 = _mm_adds_epi16(_mm_packs_epi32(vacc0x0123, vacc1x0123), voutput_zero_point);
277 __m128i vacc23x0123 = _mm_adds_epi16(_mm_packs_epi32(vacc2x0123, vacc3x0123), voutput_zero_point);
278
279 const __m128i voutput_min = _mm_load_si128((const __m128i*) params->sse2.output_min);
280 const __m128i voutput_max = _mm_load_si128((const __m128i*) params->sse2.output_max);
281 vacc01x0123 = _mm_min_epi16(_mm_max_epi16(vacc01x0123, voutput_min), voutput_max);
282 vacc23x0123 = _mm_min_epi16(_mm_max_epi16(vacc23x0123, voutput_min), voutput_max);
283
284 __m128i vout = _mm_packs_epi16(vacc01x0123, vacc23x0123);
285
286 if (nc >= 4) {
287 *((uint32_t*) c0) = (uint32_t) _mm_cvtsi128_si32(vout);
288 vout = _mm_srli_si128(vout, 4);
289 *((uint32_t*) c1) = (uint32_t) _mm_cvtsi128_si32(vout);
290 vout = _mm_srli_si128(vout, 4);
291 *((uint32_t*) c2) = (uint32_t) _mm_cvtsi128_si32(vout);
292 vout = _mm_srli_si128(vout, 4);
293 *((uint32_t*) c3) = (uint32_t) _mm_cvtsi128_si32(vout);
294
295 c0 = (int8_t*) ((uintptr_t) c0 + cn_stride);
296 c1 = (int8_t*) ((uintptr_t) c1 + cn_stride);
297 c2 = (int8_t*) ((uintptr_t) c2 + cn_stride);
298 c3 = (int8_t*) ((uintptr_t) c3 + cn_stride);
299
300 a0 = (const int8_t*) ((uintptr_t) a0 - kc);
301 a1 = (const int8_t*) ((uintptr_t) a1 - kc);
302 a2 = (const int8_t*) ((uintptr_t) a2 - kc);
303 a3 = (const int8_t*) ((uintptr_t) a3 - kc);
304
305 nc -= 4;
306 } else {
307 if (nc & 2) {
308 *((uint16_t*) c0) = (uint16_t) _mm_extract_epi16(vout, 0);
309 c0 += 2;
310 *((uint16_t*) c1) = (uint16_t) _mm_extract_epi16(vout, 2);
311 c1 += 2;
312 *((uint16_t*) c2) = (uint16_t) _mm_extract_epi16(vout, 4);
313 c2 += 2;
314 *((uint16_t*) c3) = (uint16_t) _mm_extract_epi16(vout, 6);
315 c3 += 2;
316 vout = _mm_srli_epi32(vout, 16);
317 }
318 if (nc & 1) {
319 *((int8_t*) c0) = (int8_t) _mm_cvtsi128_si32(vout);
320 *((int8_t*) c1) = (int8_t) _mm_extract_epi16(vout, 2);
321 *((int8_t*) c2) = (int8_t) _mm_extract_epi16(vout, 4);
322 *((int8_t*) c3) = (int8_t) _mm_extract_epi16(vout, 6);
323 }
324
325 nc = 0;
326 }
327 } while (nc != 0);
328 }
329