• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-dwconv/up-avx.c.in
3 //   Generator: tools/xngen
4 //
5 // Copyright 2019 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 <immintrin.h>
13 
14 #include <xnnpack/dwconv.h>
15 
16 
17 static const int32_t mask_table[14] = {-1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0};
18 
xnn_f32_dwconv_ukernel_up16x25__fma3(size_t channels,size_t output_width,const float ** input,const float * weights,float * output,size_t input_stride,size_t output_increment,const union xnn_f32_output_params params[restrict static1])19 void xnn_f32_dwconv_ukernel_up16x25__fma3(
20     size_t channels,
21     size_t output_width,
22     const float** input,
23     const float* weights,
24     float* output,
25     size_t input_stride,
26     size_t output_increment,
27     const union xnn_f32_output_params params[restrict static 1])
28 {
29   assert(channels != 0);
30   assert(output_width != 0);
31 
32   const __m256 vmax = _mm256_broadcast_ps((const __m128*) params->sse.max);
33   const __m256 vmin = _mm256_broadcast_ps((const __m128*) params->sse.min);
34   do {
35     const float* i0 = input[0];
36     assert(i0 != NULL);
37     const float* i1 = input[1];
38     assert(i1 != NULL);
39     const float* i2 = input[2];
40     assert(i2 != NULL);
41     const float* i3 = input[3];
42     assert(i3 != NULL);
43     const float* i4 = input[4];
44     assert(i4 != NULL);
45     const float* i5 = input[5];
46     assert(i5 != NULL);
47     const float* i6 = input[6];
48     assert(i6 != NULL);
49     const float* i7 = input[7];
50     assert(i7 != NULL);
51     const float* i8 = input[8];
52     assert(i8 != NULL);
53     const float* i9 = input[9];
54     assert(i9 != NULL);
55     const float* i10 = input[10];
56     assert(i10 != NULL);
57     const float* i11 = input[11];
58     assert(i11 != NULL);
59     const float* i12 = input[12];
60     assert(i12 != NULL);
61     const float* i13 = input[13];
62     assert(i13 != NULL);
63     const float* i14 = input[14];
64     assert(i14 != NULL);
65     const float* i15 = input[15];
66     assert(i15 != NULL);
67     const float* i16 = input[16];
68     assert(i16 != NULL);
69     const float* i17 = input[17];
70     assert(i17 != NULL);
71     const float* i18 = input[18];
72     assert(i18 != NULL);
73     const float* i19 = input[19];
74     assert(i19 != NULL);
75     const float* i20 = input[20];
76     assert(i20 != NULL);
77     const float* i21 = input[21];
78     assert(i21 != NULL);
79     const float* i22 = input[22];
80     assert(i22 != NULL);
81     const float* i23 = input[23];
82     assert(i23 != NULL);
83     const float* i24 = input[24];
84     assert(i24 != NULL);
85     input = (const float**) ((uintptr_t) input + input_stride);
86 
87     size_t c = channels;
88     const float* w = weights;
89     for (; c >= 16; c -= 16) {
90       __m256 vacc01234567p0 = _mm256_load_ps(w);
91       __m256 vacc89ABCDEFp0 = _mm256_load_ps(w + 8);
92 
93 
94       const __m256 vi0x01234567 = _mm256_loadu_ps(i0);
95       const __m256 vi0x89ABCDEF = _mm256_loadu_ps(i0 + 8);
96       i0 += 16;
97 
98       const __m256 vk0x01234567 = _mm256_load_ps(w + 16);
99       const __m256 vk0x89ABCDEF = _mm256_load_ps(w + 24);
100       vacc01234567p0 = _mm256_fmadd_ps(vi0x01234567, vk0x01234567, vacc01234567p0);
101       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi0x89ABCDEF, vk0x89ABCDEF, vacc89ABCDEFp0);
102 
103       const __m256 vi1x01234567 = _mm256_loadu_ps(i1);
104       const __m256 vi1x89ABCDEF = _mm256_loadu_ps(i1 + 8);
105       i1 += 16;
106 
107       const __m256 vk1x01234567 = _mm256_load_ps(w + 32);
108       const __m256 vk1x89ABCDEF = _mm256_load_ps(w + 40);
109       vacc01234567p0 = _mm256_fmadd_ps(vi1x01234567, vk1x01234567, vacc01234567p0);
110       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi1x89ABCDEF, vk1x89ABCDEF, vacc89ABCDEFp0);
111 
112       const __m256 vi2x01234567 = _mm256_loadu_ps(i2);
113       const __m256 vi2x89ABCDEF = _mm256_loadu_ps(i2 + 8);
114       i2 += 16;
115 
116       const __m256 vk2x01234567 = _mm256_load_ps(w + 48);
117       const __m256 vk2x89ABCDEF = _mm256_load_ps(w + 56);
118       vacc01234567p0 = _mm256_fmadd_ps(vi2x01234567, vk2x01234567, vacc01234567p0);
119       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi2x89ABCDEF, vk2x89ABCDEF, vacc89ABCDEFp0);
120 
121       const __m256 vi3x01234567 = _mm256_loadu_ps(i3);
122       const __m256 vi3x89ABCDEF = _mm256_loadu_ps(i3 + 8);
123       i3 += 16;
124 
125       const __m256 vk3x01234567 = _mm256_load_ps(w + 64);
126       const __m256 vk3x89ABCDEF = _mm256_load_ps(w + 72);
127       vacc01234567p0 = _mm256_fmadd_ps(vi3x01234567, vk3x01234567, vacc01234567p0);
128       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi3x89ABCDEF, vk3x89ABCDEF, vacc89ABCDEFp0);
129 
130       const __m256 vi4x01234567 = _mm256_loadu_ps(i4);
131       const __m256 vi4x89ABCDEF = _mm256_loadu_ps(i4 + 8);
132       i4 += 16;
133 
134       const __m256 vk4x01234567 = _mm256_load_ps(w + 80);
135       const __m256 vk4x89ABCDEF = _mm256_load_ps(w + 88);
136       vacc01234567p0 = _mm256_fmadd_ps(vi4x01234567, vk4x01234567, vacc01234567p0);
137       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi4x89ABCDEF, vk4x89ABCDEF, vacc89ABCDEFp0);
138 
139       const __m256 vi5x01234567 = _mm256_loadu_ps(i5);
140       const __m256 vi5x89ABCDEF = _mm256_loadu_ps(i5 + 8);
141       i5 += 16;
142 
143       const __m256 vk5x01234567 = _mm256_load_ps(w + 96);
144       const __m256 vk5x89ABCDEF = _mm256_load_ps(w + 104);
145       vacc01234567p0 = _mm256_fmadd_ps(vi5x01234567, vk5x01234567, vacc01234567p0);
146       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi5x89ABCDEF, vk5x89ABCDEF, vacc89ABCDEFp0);
147 
148       const __m256 vi6x01234567 = _mm256_loadu_ps(i6);
149       const __m256 vi6x89ABCDEF = _mm256_loadu_ps(i6 + 8);
150       i6 += 16;
151 
152       const __m256 vk6x01234567 = _mm256_load_ps(w + 112);
153       const __m256 vk6x89ABCDEF = _mm256_load_ps(w + 120);
154       vacc01234567p0 = _mm256_fmadd_ps(vi6x01234567, vk6x01234567, vacc01234567p0);
155       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi6x89ABCDEF, vk6x89ABCDEF, vacc89ABCDEFp0);
156 
157       const __m256 vi7x01234567 = _mm256_loadu_ps(i7);
158       const __m256 vi7x89ABCDEF = _mm256_loadu_ps(i7 + 8);
159       i7 += 16;
160 
161       const __m256 vk7x01234567 = _mm256_load_ps(w + 128);
162       const __m256 vk7x89ABCDEF = _mm256_load_ps(w + 136);
163       vacc01234567p0 = _mm256_fmadd_ps(vi7x01234567, vk7x01234567, vacc01234567p0);
164       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi7x89ABCDEF, vk7x89ABCDEF, vacc89ABCDEFp0);
165 
166       const __m256 vi8x01234567 = _mm256_loadu_ps(i8);
167       const __m256 vi8x89ABCDEF = _mm256_loadu_ps(i8 + 8);
168       i8 += 16;
169 
170       const __m256 vk8x01234567 = _mm256_load_ps(w + 144);
171       const __m256 vk8x89ABCDEF = _mm256_load_ps(w + 152);
172       vacc01234567p0 = _mm256_fmadd_ps(vi8x01234567, vk8x01234567, vacc01234567p0);
173       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi8x89ABCDEF, vk8x89ABCDEF, vacc89ABCDEFp0);
174 
175       const __m256 vi9x01234567 = _mm256_loadu_ps(i9);
176       const __m256 vi9x89ABCDEF = _mm256_loadu_ps(i9 + 8);
177       i9 += 16;
178 
179       const __m256 vk9x01234567 = _mm256_load_ps(w + 160);
180       const __m256 vk9x89ABCDEF = _mm256_load_ps(w + 168);
181       vacc01234567p0 = _mm256_fmadd_ps(vi9x01234567, vk9x01234567, vacc01234567p0);
182       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi9x89ABCDEF, vk9x89ABCDEF, vacc89ABCDEFp0);
183 
184       const __m256 vi10x01234567 = _mm256_loadu_ps(i10);
185       const __m256 vi10x89ABCDEF = _mm256_loadu_ps(i10 + 8);
186       i10 += 16;
187 
188       const __m256 vk10x01234567 = _mm256_load_ps(w + 176);
189       const __m256 vk10x89ABCDEF = _mm256_load_ps(w + 184);
190       vacc01234567p0 = _mm256_fmadd_ps(vi10x01234567, vk10x01234567, vacc01234567p0);
191       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi10x89ABCDEF, vk10x89ABCDEF, vacc89ABCDEFp0);
192 
193       const __m256 vi11x01234567 = _mm256_loadu_ps(i11);
194       const __m256 vi11x89ABCDEF = _mm256_loadu_ps(i11 + 8);
195       i11 += 16;
196 
197       const __m256 vk11x01234567 = _mm256_load_ps(w + 192);
198       const __m256 vk11x89ABCDEF = _mm256_load_ps(w + 200);
199       vacc01234567p0 = _mm256_fmadd_ps(vi11x01234567, vk11x01234567, vacc01234567p0);
200       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi11x89ABCDEF, vk11x89ABCDEF, vacc89ABCDEFp0);
201 
202       const __m256 vi12x01234567 = _mm256_loadu_ps(i12);
203       const __m256 vi12x89ABCDEF = _mm256_loadu_ps(i12 + 8);
204       i12 += 16;
205 
206       const __m256 vk12x01234567 = _mm256_load_ps(w + 208);
207       const __m256 vk12x89ABCDEF = _mm256_load_ps(w + 216);
208       vacc01234567p0 = _mm256_fmadd_ps(vi12x01234567, vk12x01234567, vacc01234567p0);
209       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi12x89ABCDEF, vk12x89ABCDEF, vacc89ABCDEFp0);
210 
211       const __m256 vi13x01234567 = _mm256_loadu_ps(i13);
212       const __m256 vi13x89ABCDEF = _mm256_loadu_ps(i13 + 8);
213       i13 += 16;
214 
215       const __m256 vk13x01234567 = _mm256_load_ps(w + 224);
216       const __m256 vk13x89ABCDEF = _mm256_load_ps(w + 232);
217       vacc01234567p0 = _mm256_fmadd_ps(vi13x01234567, vk13x01234567, vacc01234567p0);
218       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi13x89ABCDEF, vk13x89ABCDEF, vacc89ABCDEFp0);
219 
220       const __m256 vi14x01234567 = _mm256_loadu_ps(i14);
221       const __m256 vi14x89ABCDEF = _mm256_loadu_ps(i14 + 8);
222       i14 += 16;
223 
224       const __m256 vk14x01234567 = _mm256_load_ps(w + 240);
225       const __m256 vk14x89ABCDEF = _mm256_load_ps(w + 248);
226       vacc01234567p0 = _mm256_fmadd_ps(vi14x01234567, vk14x01234567, vacc01234567p0);
227       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi14x89ABCDEF, vk14x89ABCDEF, vacc89ABCDEFp0);
228 
229       const __m256 vi15x01234567 = _mm256_loadu_ps(i15);
230       const __m256 vi15x89ABCDEF = _mm256_loadu_ps(i15 + 8);
231       i15 += 16;
232 
233       const __m256 vk15x01234567 = _mm256_load_ps(w + 256);
234       const __m256 vk15x89ABCDEF = _mm256_load_ps(w + 264);
235       vacc01234567p0 = _mm256_fmadd_ps(vi15x01234567, vk15x01234567, vacc01234567p0);
236       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi15x89ABCDEF, vk15x89ABCDEF, vacc89ABCDEFp0);
237 
238       const __m256 vi16x01234567 = _mm256_loadu_ps(i16);
239       const __m256 vi16x89ABCDEF = _mm256_loadu_ps(i16 + 8);
240       i16 += 16;
241 
242       const __m256 vk16x01234567 = _mm256_load_ps(w + 272);
243       const __m256 vk16x89ABCDEF = _mm256_load_ps(w + 280);
244       vacc01234567p0 = _mm256_fmadd_ps(vi16x01234567, vk16x01234567, vacc01234567p0);
245       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi16x89ABCDEF, vk16x89ABCDEF, vacc89ABCDEFp0);
246 
247       const __m256 vi17x01234567 = _mm256_loadu_ps(i17);
248       const __m256 vi17x89ABCDEF = _mm256_loadu_ps(i17 + 8);
249       i17 += 16;
250 
251       const __m256 vk17x01234567 = _mm256_load_ps(w + 288);
252       const __m256 vk17x89ABCDEF = _mm256_load_ps(w + 296);
253       vacc01234567p0 = _mm256_fmadd_ps(vi17x01234567, vk17x01234567, vacc01234567p0);
254       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi17x89ABCDEF, vk17x89ABCDEF, vacc89ABCDEFp0);
255 
256       const __m256 vi18x01234567 = _mm256_loadu_ps(i18);
257       const __m256 vi18x89ABCDEF = _mm256_loadu_ps(i18 + 8);
258       i18 += 16;
259 
260       const __m256 vk18x01234567 = _mm256_load_ps(w + 304);
261       const __m256 vk18x89ABCDEF = _mm256_load_ps(w + 312);
262       vacc01234567p0 = _mm256_fmadd_ps(vi18x01234567, vk18x01234567, vacc01234567p0);
263       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi18x89ABCDEF, vk18x89ABCDEF, vacc89ABCDEFp0);
264 
265       const __m256 vi19x01234567 = _mm256_loadu_ps(i19);
266       const __m256 vi19x89ABCDEF = _mm256_loadu_ps(i19 + 8);
267       i19 += 16;
268 
269       const __m256 vk19x01234567 = _mm256_load_ps(w + 320);
270       const __m256 vk19x89ABCDEF = _mm256_load_ps(w + 328);
271       vacc01234567p0 = _mm256_fmadd_ps(vi19x01234567, vk19x01234567, vacc01234567p0);
272       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi19x89ABCDEF, vk19x89ABCDEF, vacc89ABCDEFp0);
273 
274       const __m256 vi20x01234567 = _mm256_loadu_ps(i20);
275       const __m256 vi20x89ABCDEF = _mm256_loadu_ps(i20 + 8);
276       i20 += 16;
277 
278       const __m256 vk20x01234567 = _mm256_load_ps(w + 336);
279       const __m256 vk20x89ABCDEF = _mm256_load_ps(w + 344);
280       vacc01234567p0 = _mm256_fmadd_ps(vi20x01234567, vk20x01234567, vacc01234567p0);
281       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi20x89ABCDEF, vk20x89ABCDEF, vacc89ABCDEFp0);
282 
283       const __m256 vi21x01234567 = _mm256_loadu_ps(i21);
284       const __m256 vi21x89ABCDEF = _mm256_loadu_ps(i21 + 8);
285       i21 += 16;
286 
287       const __m256 vk21x01234567 = _mm256_load_ps(w + 352);
288       const __m256 vk21x89ABCDEF = _mm256_load_ps(w + 360);
289       vacc01234567p0 = _mm256_fmadd_ps(vi21x01234567, vk21x01234567, vacc01234567p0);
290       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi21x89ABCDEF, vk21x89ABCDEF, vacc89ABCDEFp0);
291 
292       const __m256 vi22x01234567 = _mm256_loadu_ps(i22);
293       const __m256 vi22x89ABCDEF = _mm256_loadu_ps(i22 + 8);
294       i22 += 16;
295 
296       const __m256 vk22x01234567 = _mm256_load_ps(w + 368);
297       const __m256 vk22x89ABCDEF = _mm256_load_ps(w + 376);
298       vacc01234567p0 = _mm256_fmadd_ps(vi22x01234567, vk22x01234567, vacc01234567p0);
299       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi22x89ABCDEF, vk22x89ABCDEF, vacc89ABCDEFp0);
300 
301       const __m256 vi23x01234567 = _mm256_loadu_ps(i23);
302       const __m256 vi23x89ABCDEF = _mm256_loadu_ps(i23 + 8);
303       i23 += 16;
304 
305       const __m256 vk23x01234567 = _mm256_load_ps(w + 384);
306       const __m256 vk23x89ABCDEF = _mm256_load_ps(w + 392);
307       vacc01234567p0 = _mm256_fmadd_ps(vi23x01234567, vk23x01234567, vacc01234567p0);
308       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi23x89ABCDEF, vk23x89ABCDEF, vacc89ABCDEFp0);
309 
310       const __m256 vi24x01234567 = _mm256_loadu_ps(i24);
311       const __m256 vi24x89ABCDEF = _mm256_loadu_ps(i24 + 8);
312       i24 += 16;
313 
314       const __m256 vk24x01234567 = _mm256_load_ps(w + 400);
315       const __m256 vk24x89ABCDEF = _mm256_load_ps(w + 408);
316       vacc01234567p0 = _mm256_fmadd_ps(vi24x01234567, vk24x01234567, vacc01234567p0);
317       vacc89ABCDEFp0 = _mm256_fmadd_ps(vi24x89ABCDEF, vk24x89ABCDEF, vacc89ABCDEFp0);
318 
319       w += 416;
320 
321 
322       __m256 vacc01234567 = _mm256_max_ps(vacc01234567p0, vmin);
323       __m256 vacc89ABCDEF = _mm256_max_ps(vacc89ABCDEFp0, vmin);
324       vacc01234567 = _mm256_min_ps(vacc01234567, vmax);
325       vacc89ABCDEF = _mm256_min_ps(vacc89ABCDEF, vmax);
326 
327       _mm256_storeu_ps(output, vacc01234567);
328       _mm256_storeu_ps(output + 8, vacc89ABCDEF);
329       output += 16;
330     }
331     for (; c >= 8; c -= 8) {
332       __m256 vacc01234567p0 = _mm256_load_ps(w);
333 
334       const __m256 vi0x01234567 = _mm256_loadu_ps(i0);
335       i0 += 8;
336 
337       const __m256 vk0x01234567 = _mm256_load_ps(w + 16);
338       vacc01234567p0 = _mm256_fmadd_ps(vi0x01234567, vk0x01234567, vacc01234567p0);
339 
340       const __m256 vi1x01234567 = _mm256_loadu_ps(i1);
341       i1 += 8;
342 
343       const __m256 vk1x01234567 = _mm256_load_ps(w + 32);
344       vacc01234567p0 = _mm256_fmadd_ps(vi1x01234567, vk1x01234567, vacc01234567p0);
345 
346       const __m256 vi2x01234567 = _mm256_loadu_ps(i2);
347       i2 += 8;
348 
349       const __m256 vk2x01234567 = _mm256_load_ps(w + 48);
350       vacc01234567p0 = _mm256_fmadd_ps(vi2x01234567, vk2x01234567, vacc01234567p0);
351 
352       const __m256 vi3x01234567 = _mm256_loadu_ps(i3);
353       i3 += 8;
354 
355       const __m256 vk3x01234567 = _mm256_load_ps(w + 64);
356       vacc01234567p0 = _mm256_fmadd_ps(vi3x01234567, vk3x01234567, vacc01234567p0);
357 
358       const __m256 vi4x01234567 = _mm256_loadu_ps(i4);
359       i4 += 8;
360 
361       const __m256 vk4x01234567 = _mm256_load_ps(w + 80);
362       vacc01234567p0 = _mm256_fmadd_ps(vi4x01234567, vk4x01234567, vacc01234567p0);
363 
364       const __m256 vi5x01234567 = _mm256_loadu_ps(i5);
365       i5 += 8;
366 
367       const __m256 vk5x01234567 = _mm256_load_ps(w + 96);
368       vacc01234567p0 = _mm256_fmadd_ps(vi5x01234567, vk5x01234567, vacc01234567p0);
369 
370       const __m256 vi6x01234567 = _mm256_loadu_ps(i6);
371       i6 += 8;
372 
373       const __m256 vk6x01234567 = _mm256_load_ps(w + 112);
374       vacc01234567p0 = _mm256_fmadd_ps(vi6x01234567, vk6x01234567, vacc01234567p0);
375 
376       const __m256 vi7x01234567 = _mm256_loadu_ps(i7);
377       i7 += 8;
378 
379       const __m256 vk7x01234567 = _mm256_load_ps(w + 128);
380       vacc01234567p0 = _mm256_fmadd_ps(vi7x01234567, vk7x01234567, vacc01234567p0);
381 
382       const __m256 vi8x01234567 = _mm256_loadu_ps(i8);
383       i8 += 8;
384 
385       const __m256 vk8x01234567 = _mm256_load_ps(w + 144);
386       vacc01234567p0 = _mm256_fmadd_ps(vi8x01234567, vk8x01234567, vacc01234567p0);
387 
388       const __m256 vi9x01234567 = _mm256_loadu_ps(i9);
389       i9 += 8;
390 
391       const __m256 vk9x01234567 = _mm256_load_ps(w + 160);
392       vacc01234567p0 = _mm256_fmadd_ps(vi9x01234567, vk9x01234567, vacc01234567p0);
393 
394       const __m256 vi10x01234567 = _mm256_loadu_ps(i10);
395       i10 += 8;
396 
397       const __m256 vk10x01234567 = _mm256_load_ps(w + 176);
398       vacc01234567p0 = _mm256_fmadd_ps(vi10x01234567, vk10x01234567, vacc01234567p0);
399 
400       const __m256 vi11x01234567 = _mm256_loadu_ps(i11);
401       i11 += 8;
402 
403       const __m256 vk11x01234567 = _mm256_load_ps(w + 192);
404       vacc01234567p0 = _mm256_fmadd_ps(vi11x01234567, vk11x01234567, vacc01234567p0);
405 
406       const __m256 vi12x01234567 = _mm256_loadu_ps(i12);
407       i12 += 8;
408 
409       const __m256 vk12x01234567 = _mm256_load_ps(w + 208);
410       vacc01234567p0 = _mm256_fmadd_ps(vi12x01234567, vk12x01234567, vacc01234567p0);
411 
412       const __m256 vi13x01234567 = _mm256_loadu_ps(i13);
413       i13 += 8;
414 
415       const __m256 vk13x01234567 = _mm256_load_ps(w + 224);
416       vacc01234567p0 = _mm256_fmadd_ps(vi13x01234567, vk13x01234567, vacc01234567p0);
417 
418       const __m256 vi14x01234567 = _mm256_loadu_ps(i14);
419       i14 += 8;
420 
421       const __m256 vk14x01234567 = _mm256_load_ps(w + 240);
422       vacc01234567p0 = _mm256_fmadd_ps(vi14x01234567, vk14x01234567, vacc01234567p0);
423 
424       const __m256 vi15x01234567 = _mm256_loadu_ps(i15);
425       i15 += 8;
426 
427       const __m256 vk15x01234567 = _mm256_load_ps(w + 256);
428       vacc01234567p0 = _mm256_fmadd_ps(vi15x01234567, vk15x01234567, vacc01234567p0);
429 
430       const __m256 vi16x01234567 = _mm256_loadu_ps(i16);
431       i16 += 8;
432 
433       const __m256 vk16x01234567 = _mm256_load_ps(w + 272);
434       vacc01234567p0 = _mm256_fmadd_ps(vi16x01234567, vk16x01234567, vacc01234567p0);
435 
436       const __m256 vi17x01234567 = _mm256_loadu_ps(i17);
437       i17 += 8;
438 
439       const __m256 vk17x01234567 = _mm256_load_ps(w + 288);
440       vacc01234567p0 = _mm256_fmadd_ps(vi17x01234567, vk17x01234567, vacc01234567p0);
441 
442       const __m256 vi18x01234567 = _mm256_loadu_ps(i18);
443       i18 += 8;
444 
445       const __m256 vk18x01234567 = _mm256_load_ps(w + 304);
446       vacc01234567p0 = _mm256_fmadd_ps(vi18x01234567, vk18x01234567, vacc01234567p0);
447 
448       const __m256 vi19x01234567 = _mm256_loadu_ps(i19);
449       i19 += 8;
450 
451       const __m256 vk19x01234567 = _mm256_load_ps(w + 320);
452       vacc01234567p0 = _mm256_fmadd_ps(vi19x01234567, vk19x01234567, vacc01234567p0);
453 
454       const __m256 vi20x01234567 = _mm256_loadu_ps(i20);
455       i20 += 8;
456 
457       const __m256 vk20x01234567 = _mm256_load_ps(w + 336);
458       vacc01234567p0 = _mm256_fmadd_ps(vi20x01234567, vk20x01234567, vacc01234567p0);
459 
460       const __m256 vi21x01234567 = _mm256_loadu_ps(i21);
461       i21 += 8;
462 
463       const __m256 vk21x01234567 = _mm256_load_ps(w + 352);
464       vacc01234567p0 = _mm256_fmadd_ps(vi21x01234567, vk21x01234567, vacc01234567p0);
465 
466       const __m256 vi22x01234567 = _mm256_loadu_ps(i22);
467       i22 += 8;
468 
469       const __m256 vk22x01234567 = _mm256_load_ps(w + 368);
470       vacc01234567p0 = _mm256_fmadd_ps(vi22x01234567, vk22x01234567, vacc01234567p0);
471 
472       const __m256 vi23x01234567 = _mm256_loadu_ps(i23);
473       i23 += 8;
474 
475       const __m256 vk23x01234567 = _mm256_load_ps(w + 384);
476       vacc01234567p0 = _mm256_fmadd_ps(vi23x01234567, vk23x01234567, vacc01234567p0);
477 
478       const __m256 vi24x01234567 = _mm256_loadu_ps(i24);
479       i24 += 8;
480 
481       const __m256 vk24x01234567 = _mm256_load_ps(w + 400);
482       vacc01234567p0 = _mm256_fmadd_ps(vi24x01234567, vk24x01234567, vacc01234567p0);
483 
484       w += 8;
485 
486 
487       __m256 vacc01234567 = _mm256_max_ps(vacc01234567p0, vmin);
488       vacc01234567 = _mm256_min_ps(vacc01234567, vmax);
489 
490       _mm256_storeu_ps(output, vacc01234567);
491       output += 8;
492     }
493     if XNN_UNLIKELY(c != 0) {
494       assert(c >= 1);
495       assert(c <= 7);
496       __m256i vmask = _mm256_loadu_si256((const __m256i*) &mask_table[7 - c]);
497 
498       __m256 vacc01234567p0 = _mm256_load_ps(w);
499 
500       const __m256 vi0x01234567 = _mm256_maskload_ps(i0, vmask);
501       const __m256 vk0x01234567 = _mm256_load_ps(w + 16);
502       vacc01234567p0 = _mm256_fmadd_ps(vi0x01234567, vk0x01234567, vacc01234567p0);
503 
504       const __m256 vi1x01234567 = _mm256_maskload_ps(i1, vmask);
505       const __m256 vk1x01234567 = _mm256_load_ps(w + 32);
506       vacc01234567p0 = _mm256_fmadd_ps(vi1x01234567, vk1x01234567, vacc01234567p0);
507 
508       const __m256 vi2x01234567 = _mm256_maskload_ps(i2, vmask);
509       const __m256 vk2x01234567 = _mm256_load_ps(w + 48);
510       vacc01234567p0 = _mm256_fmadd_ps(vi2x01234567, vk2x01234567, vacc01234567p0);
511 
512       const __m256 vi3x01234567 = _mm256_maskload_ps(i3, vmask);
513       const __m256 vk3x01234567 = _mm256_load_ps(w + 64);
514       vacc01234567p0 = _mm256_fmadd_ps(vi3x01234567, vk3x01234567, vacc01234567p0);
515 
516       const __m256 vi4x01234567 = _mm256_maskload_ps(i4, vmask);
517       const __m256 vk4x01234567 = _mm256_load_ps(w + 80);
518       vacc01234567p0 = _mm256_fmadd_ps(vi4x01234567, vk4x01234567, vacc01234567p0);
519 
520       const __m256 vi5x01234567 = _mm256_maskload_ps(i5, vmask);
521       const __m256 vk5x01234567 = _mm256_load_ps(w + 96);
522       vacc01234567p0 = _mm256_fmadd_ps(vi5x01234567, vk5x01234567, vacc01234567p0);
523 
524       const __m256 vi6x01234567 = _mm256_maskload_ps(i6, vmask);
525       const __m256 vk6x01234567 = _mm256_load_ps(w + 112);
526       vacc01234567p0 = _mm256_fmadd_ps(vi6x01234567, vk6x01234567, vacc01234567p0);
527 
528       const __m256 vi7x01234567 = _mm256_maskload_ps(i7, vmask);
529       const __m256 vk7x01234567 = _mm256_load_ps(w + 128);
530       vacc01234567p0 = _mm256_fmadd_ps(vi7x01234567, vk7x01234567, vacc01234567p0);
531 
532       const __m256 vi8x01234567 = _mm256_maskload_ps(i8, vmask);
533       const __m256 vk8x01234567 = _mm256_load_ps(w + 144);
534       vacc01234567p0 = _mm256_fmadd_ps(vi8x01234567, vk8x01234567, vacc01234567p0);
535 
536       const __m256 vi9x01234567 = _mm256_maskload_ps(i9, vmask);
537       const __m256 vk9x01234567 = _mm256_load_ps(w + 160);
538       vacc01234567p0 = _mm256_fmadd_ps(vi9x01234567, vk9x01234567, vacc01234567p0);
539 
540       const __m256 vi10x01234567 = _mm256_maskload_ps(i10, vmask);
541       const __m256 vk10x01234567 = _mm256_load_ps(w + 176);
542       vacc01234567p0 = _mm256_fmadd_ps(vi10x01234567, vk10x01234567, vacc01234567p0);
543 
544       const __m256 vi11x01234567 = _mm256_maskload_ps(i11, vmask);
545       const __m256 vk11x01234567 = _mm256_load_ps(w + 192);
546       vacc01234567p0 = _mm256_fmadd_ps(vi11x01234567, vk11x01234567, vacc01234567p0);
547 
548       const __m256 vi12x01234567 = _mm256_maskload_ps(i12, vmask);
549       const __m256 vk12x01234567 = _mm256_load_ps(w + 208);
550       vacc01234567p0 = _mm256_fmadd_ps(vi12x01234567, vk12x01234567, vacc01234567p0);
551 
552       const __m256 vi13x01234567 = _mm256_maskload_ps(i13, vmask);
553       const __m256 vk13x01234567 = _mm256_load_ps(w + 224);
554       vacc01234567p0 = _mm256_fmadd_ps(vi13x01234567, vk13x01234567, vacc01234567p0);
555 
556       const __m256 vi14x01234567 = _mm256_maskload_ps(i14, vmask);
557       const __m256 vk14x01234567 = _mm256_load_ps(w + 240);
558       vacc01234567p0 = _mm256_fmadd_ps(vi14x01234567, vk14x01234567, vacc01234567p0);
559 
560       const __m256 vi15x01234567 = _mm256_maskload_ps(i15, vmask);
561       const __m256 vk15x01234567 = _mm256_load_ps(w + 256);
562       vacc01234567p0 = _mm256_fmadd_ps(vi15x01234567, vk15x01234567, vacc01234567p0);
563 
564       const __m256 vi16x01234567 = _mm256_maskload_ps(i16, vmask);
565       const __m256 vk16x01234567 = _mm256_load_ps(w + 272);
566       vacc01234567p0 = _mm256_fmadd_ps(vi16x01234567, vk16x01234567, vacc01234567p0);
567 
568       const __m256 vi17x01234567 = _mm256_maskload_ps(i17, vmask);
569       const __m256 vk17x01234567 = _mm256_load_ps(w + 288);
570       vacc01234567p0 = _mm256_fmadd_ps(vi17x01234567, vk17x01234567, vacc01234567p0);
571 
572       const __m256 vi18x01234567 = _mm256_maskload_ps(i18, vmask);
573       const __m256 vk18x01234567 = _mm256_load_ps(w + 304);
574       vacc01234567p0 = _mm256_fmadd_ps(vi18x01234567, vk18x01234567, vacc01234567p0);
575 
576       const __m256 vi19x01234567 = _mm256_maskload_ps(i19, vmask);
577       const __m256 vk19x01234567 = _mm256_load_ps(w + 320);
578       vacc01234567p0 = _mm256_fmadd_ps(vi19x01234567, vk19x01234567, vacc01234567p0);
579 
580       const __m256 vi20x01234567 = _mm256_maskload_ps(i20, vmask);
581       const __m256 vk20x01234567 = _mm256_load_ps(w + 336);
582       vacc01234567p0 = _mm256_fmadd_ps(vi20x01234567, vk20x01234567, vacc01234567p0);
583 
584       const __m256 vi21x01234567 = _mm256_maskload_ps(i21, vmask);
585       const __m256 vk21x01234567 = _mm256_load_ps(w + 352);
586       vacc01234567p0 = _mm256_fmadd_ps(vi21x01234567, vk21x01234567, vacc01234567p0);
587 
588       const __m256 vi22x01234567 = _mm256_maskload_ps(i22, vmask);
589       const __m256 vk22x01234567 = _mm256_load_ps(w + 368);
590       vacc01234567p0 = _mm256_fmadd_ps(vi22x01234567, vk22x01234567, vacc01234567p0);
591 
592       const __m256 vi23x01234567 = _mm256_maskload_ps(i23, vmask);
593       const __m256 vk23x01234567 = _mm256_load_ps(w + 384);
594       vacc01234567p0 = _mm256_fmadd_ps(vi23x01234567, vk23x01234567, vacc01234567p0);
595 
596       const __m256 vi24x01234567 = _mm256_maskload_ps(i24, vmask);
597       const __m256 vk24x01234567 = _mm256_load_ps(w + 400);
598       vacc01234567p0 = _mm256_fmadd_ps(vi24x01234567, vk24x01234567, vacc01234567p0);
599 
600 
601       __m256 vacc01234567 = _mm256_max_ps(vacc01234567p0, vmin);
602       vacc01234567 = _mm256_min_ps(vacc01234567, vmax);
603 
604       // _mm256_maskstore_ps(output, vmask, vacc01234567); output += c; could be used here, but triggers msan failures (probably an msan bug).
605       __m128 vacc0123 = _mm256_castps256_ps128(vacc01234567);
606       if (c & 4) {
607         _mm_storeu_ps(output, vacc0123);
608         vacc0123 = _mm256_extractf128_ps(vacc01234567, 1);
609         output += 4;
610       }
611       if (c & 2) {
612         _mm_storel_pi((__m64*) output, vacc0123);
613         vacc0123 = _mm_movehl_ps(vacc0123, vacc0123);
614         output += 2;
615       }
616       if (c & 1) {
617         _mm_store_ss(output, vacc0123);
618         output += 1;
619       }
620     }
621 
622     output = (float*) ((uintptr_t) output + output_increment);
623   } while (--output_width != 0);
624 }
625