1 // Auto-generated file. Do not edit!
2 // Template: src/f32-dwconv2d-chw/3x3p1-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 <xmmintrin.h>
13
14 #include <xnnpack/dwconv.h>
15 #include <xnnpack/math.h>
16
17
xnn_f32_dwconv2d_chw_ukernel_3x3p1__sse_4x4(size_t input_height,size_t input_width,const float * input,const float * weights,const float * zero,float * output,uint32_t padding_top,const union xnn_f32_chw_params params[restrict XNN_MIN_ELEMENTS (1)])18 void xnn_f32_dwconv2d_chw_ukernel_3x3p1__sse_4x4(
19 size_t input_height,
20 size_t input_width,
21 const float* input,
22 const float* weights,
23 const float* zero,
24 float* output,
25 uint32_t padding_top,
26 const union xnn_f32_chw_params params[restrict XNN_MIN_ELEMENTS(1)])
27 {
28 assert(input_height != 0);
29 assert(input_width != 0);
30 assert(input_width % sizeof(float) == 0);
31 assert(padding_top == 1);
32
33 const __m128 vmask = _mm_load_ps((const float*) params->sse.mask);
34 const __m128 vmax = _mm_load_ps(params->sse.max);
35 const __m128 vmin = _mm_load_ps(params->sse.min);
36
37 const __m128 vbias = _mm_load1_ps(weights);
38 const __m128 vk00 = _mm_load1_ps(weights + 1);
39 const __m128 vk01 = _mm_load1_ps(weights + 2);
40 const __m128 vk02 = _mm_load1_ps(weights + 3);
41 const __m128 vk10 = _mm_load1_ps(weights + 4);
42 const __m128 vk11 = _mm_load1_ps(weights + 5);
43 const __m128 vk12 = _mm_load1_ps(weights + 6);
44 const __m128 vk20 = _mm_load1_ps(weights + 7);
45 const __m128 vk21 = _mm_load1_ps(weights + 8);
46 const __m128 vk22 = _mm_load1_ps(weights + 9);
47
48 const size_t input_decrement = round_up_po2(input_width, 4 * sizeof(float));
49
50 const float* i0 = zero;
51 const float* i1 = input;
52 const float* i2 = (const float*) ((uintptr_t) i1 + input_width);
53 const float* i3 = (const float*) ((uintptr_t) i2 + input_width);
54 const float* i4 = (const float*) ((uintptr_t) i3 + input_width);
55 const float* i5 = (const float*) ((uintptr_t) i4 + input_width);
56
57 float* o0 = output;
58 float* o1 = (float*) ((uintptr_t) o0 + input_width);
59 float* o2 = (float*) ((uintptr_t) o1 + input_width);
60 float* o3 = (float*) ((uintptr_t) o2 + input_width);
61
62 size_t output_height = input_height;
63 do {
64 if XNN_UNPREDICTABLE(output_height < 2) {
65 i2 = zero;
66 o1 = o0;
67 }
68 if XNN_UNPREDICTABLE(output_height < 3) {
69 i3 = zero;
70 o2 = o1;
71 }
72 if XNN_UNPREDICTABLE(output_height < 4) {
73 i4 = zero;
74 o3 = o2;
75 }
76 if XNN_UNPREDICTABLE(output_height < 5) {
77 i5 = zero;
78 }
79
80 // vi0x3012 = ( vi02, vi01, vi{M}0, vi{M}3 )
81 __m128 vi0x3012 = _mm_setzero_ps();
82 // vi1x3012 = ( vi12, vi11, vi{M}0, vi{M}3 )
83 __m128 vi1x3012 = _mm_setzero_ps();
84 // vi2x3012 = ( vi22, vi21, vi{M}0, vi{M}3 )
85 __m128 vi2x3012 = _mm_setzero_ps();
86 // vi3x3012 = ( vi32, vi31, vi{M}0, vi{M}3 )
87 __m128 vi3x3012 = _mm_setzero_ps();
88 // vi4x3012 = ( vi42, vi41, vi{M}0, vi{M}3 )
89 __m128 vi4x3012 = _mm_setzero_ps();
90 // vi5x3012 = ( vi52, vi51, vi{M}0, vi{M}3 )
91 __m128 vi5x3012 = _mm_setzero_ps();
92
93 __m128 vi0x4567 = _mm_loadu_ps(i0);
94 i0 += 4;
95 __m128 vi1x4567 = _mm_loadu_ps(i1);
96 i1 += 4;
97 __m128 vi2x4567 = _mm_loadu_ps(i2);
98 i2 += 4;
99 __m128 vi3x4567 = _mm_loadu_ps(i3);
100 i3 += 4;
101 __m128 vi4x4567 = _mm_loadu_ps(i4);
102 i4 += 4;
103 __m128 vi5x4567 = _mm_loadu_ps(i5);
104 i5 += 4;
105
106 size_t w = input_width;
107 for (; w > 4 * sizeof(float); w -= 4 * sizeof(float)) {
108 // vi0x89AB = ( vi0B, vi0A, vi09, vi08 )
109 const __m128 vi0x89AB = _mm_loadu_ps(i0);
110 i0 += 4;
111 // vi1x89AB = ( vi1B, vi1A, vi19, vi18 )
112 const __m128 vi1x89AB = _mm_loadu_ps(i1);
113 i1 += 4;
114 // vi2x89AB = ( vi2B, vi2A, vi29, vi28 )
115 const __m128 vi2x89AB = _mm_loadu_ps(i2);
116 i2 += 4;
117 // vi3x89AB = ( vi3B, vi3A, vi39, vi38 )
118 const __m128 vi3x89AB = _mm_loadu_ps(i3);
119 i3 += 4;
120 // vi4x89AB = ( vi4B, vi4A, vi49, vi48 )
121 const __m128 vi4x89AB = _mm_loadu_ps(i4);
122 i4 += 4;
123 // vi5x89AB = ( vi5B, vi5A, vi59, vi58 )
124 const __m128 vi5x89AB = _mm_loadu_ps(i5);
125 i5 += 4;
126
127 // vi0x7456 = ( vi06, vi05, vi04, vi07 )
128 const __m128 vi0x7456 = _mm_shuffle_ps(vi0x4567, vi0x4567, _MM_SHUFFLE(2, 1, 0, 3));
129 // vi1x7456 = ( vi16, vi15, vi14, vi17 )
130 const __m128 vi1x7456 = _mm_shuffle_ps(vi1x4567, vi1x4567, _MM_SHUFFLE(2, 1, 0, 3));
131 // vi2x7456 = ( vi26, vi25, vi24, vi27 )
132 const __m128 vi2x7456 = _mm_shuffle_ps(vi2x4567, vi2x4567, _MM_SHUFFLE(2, 1, 0, 3));
133 // vi3x7456 = ( vi36, vi35, vi34, vi37 )
134 const __m128 vi3x7456 = _mm_shuffle_ps(vi3x4567, vi3x4567, _MM_SHUFFLE(2, 1, 0, 3));
135 // vi4x7456 = ( vi46, vi45, vi44, vi47 )
136 const __m128 vi4x7456 = _mm_shuffle_ps(vi4x4567, vi4x4567, _MM_SHUFFLE(2, 1, 0, 3));
137 // vi5x7456 = ( vi56, vi55, vi54, vi57 )
138 const __m128 vi5x7456 = _mm_shuffle_ps(vi5x4567, vi5x4567, _MM_SHUFFLE(2, 1, 0, 3));
139
140 __m128 vo0p0 = _mm_add_ps(vbias, _mm_mul_ps(vi0x4567, vk01));
141 __m128 vo1p0 = _mm_add_ps(vbias, _mm_mul_ps(vi1x4567, vk01));
142 __m128 vo2p0 = _mm_add_ps(vbias, _mm_mul_ps(vi2x4567, vk01));
143 __m128 vo3p0 = _mm_add_ps(vbias, _mm_mul_ps(vi3x4567, vk01));
144 vo0p0 = _mm_add_ps(vo0p0, _mm_mul_ps(vi1x4567, vk11));
145 vo1p0 = _mm_add_ps(vo1p0, _mm_mul_ps(vi2x4567, vk11));
146 vo2p0 = _mm_add_ps(vo2p0, _mm_mul_ps(vi3x4567, vk11));
147 vo3p0 = _mm_add_ps(vo3p0, _mm_mul_ps(vi4x4567, vk11));
148 vo0p0 = _mm_add_ps(vo0p0, _mm_mul_ps(vi2x4567, vk21));
149 vo1p0 = _mm_add_ps(vo1p0, _mm_mul_ps(vi3x4567, vk21));
150 vo2p0 = _mm_add_ps(vo2p0, _mm_mul_ps(vi4x4567, vk21));
151 vo3p0 = _mm_add_ps(vo3p0, _mm_mul_ps(vi5x4567, vk21));
152
153 // vi0x3456 = ( vi06, vi05, vi04, vi03 )
154 const __m128 vi0x3456 = _mm_move_ss(vi0x7456, vi0x3012);
155 // vi1x3456 = ( vi16, vi15, vi14, vi13 )
156 const __m128 vi1x3456 = _mm_move_ss(vi1x7456, vi1x3012);
157 // vi2x3456 = ( vi26, vi25, vi24, vi23 )
158 const __m128 vi2x3456 = _mm_move_ss(vi2x7456, vi2x3012);
159 // vi3x3456 = ( vi36, vi35, vi34, vi33 )
160 const __m128 vi3x3456 = _mm_move_ss(vi3x7456, vi3x3012);
161 // vi4x3456 = ( vi46, vi45, vi44, vi43 )
162 const __m128 vi4x3456 = _mm_move_ss(vi4x7456, vi4x3012);
163 // vi5x3456 = ( vi56, vi55, vi54, vi53 )
164 const __m128 vi5x3456 = _mm_move_ss(vi5x7456, vi5x3012);
165
166 vo0p0 = _mm_add_ps(vo0p0, _mm_mul_ps(vi0x3456, vk00));
167 vo1p0 = _mm_add_ps(vo1p0, _mm_mul_ps(vi1x3456, vk00));
168 vo2p0 = _mm_add_ps(vo2p0, _mm_mul_ps(vi2x3456, vk00));
169 vo3p0 = _mm_add_ps(vo3p0, _mm_mul_ps(vi3x3456, vk00));
170 vo0p0 = _mm_add_ps(vo0p0, _mm_mul_ps(vi1x3456, vk10));
171 vo1p0 = _mm_add_ps(vo1p0, _mm_mul_ps(vi2x3456, vk10));
172 vo2p0 = _mm_add_ps(vo2p0, _mm_mul_ps(vi3x3456, vk10));
173 vo3p0 = _mm_add_ps(vo3p0, _mm_mul_ps(vi4x3456, vk10));
174 vo0p0 = _mm_add_ps(vo0p0, _mm_mul_ps(vi2x3456, vk20));
175 vo1p0 = _mm_add_ps(vo1p0, _mm_mul_ps(vi3x3456, vk20));
176 vo2p0 = _mm_add_ps(vo2p0, _mm_mul_ps(vi4x3456, vk20));
177 vo3p0 = _mm_add_ps(vo3p0, _mm_mul_ps(vi5x3456, vk20));
178
179 vi0x3012 = vi0x7456;
180 vi1x3012 = vi1x7456;
181 vi2x3012 = vi2x7456;
182 vi3x3012 = vi3x7456;
183 vi4x3012 = vi4x7456;
184 vi5x3012 = vi5x7456;
185
186 // vi0x8567 = ( vi07, vi06, vi05, vi08 )
187 const __m128 vi0x8567 = _mm_move_ss(vi0x4567, vi0x89AB);
188 // vi1x8567 = ( vi17, vi16, vi15, vi18 )
189 const __m128 vi1x8567 = _mm_move_ss(vi1x4567, vi1x89AB);
190 // vi2x8567 = ( vi27, vi26, vi25, vi28 )
191 const __m128 vi2x8567 = _mm_move_ss(vi2x4567, vi2x89AB);
192 // vi3x8567 = ( vi37, vi36, vi35, vi38 )
193 const __m128 vi3x8567 = _mm_move_ss(vi3x4567, vi3x89AB);
194 // vi4x8567 = ( vi47, vi46, vi45, vi48 )
195 const __m128 vi4x8567 = _mm_move_ss(vi4x4567, vi4x89AB);
196 // vi5x8567 = ( vi57, vi56, vi55, vi58 )
197 const __m128 vi5x8567 = _mm_move_ss(vi5x4567, vi5x89AB);
198
199 // vi0x5678 = ( vi08, vi07, vi06, vi05 )
200 const __m128 vi0x5678 = _mm_shuffle_ps(vi0x8567, vi0x8567, _MM_SHUFFLE(0, 3, 2, 1));
201 // vi1x5678 = ( vi18, vi17, vi16, vi15 )
202 const __m128 vi1x5678 = _mm_shuffle_ps(vi1x8567, vi1x8567, _MM_SHUFFLE(0, 3, 2, 1));
203 // vi2x5678 = ( vi28, vi27, vi26, vi25 )
204 const __m128 vi2x5678 = _mm_shuffle_ps(vi2x8567, vi2x8567, _MM_SHUFFLE(0, 3, 2, 1));
205 // vi3x5678 = ( vi38, vi37, vi36, vi35 )
206 const __m128 vi3x5678 = _mm_shuffle_ps(vi3x8567, vi3x8567, _MM_SHUFFLE(0, 3, 2, 1));
207 // vi4x5678 = ( vi48, vi47, vi46, vi45 )
208 const __m128 vi4x5678 = _mm_shuffle_ps(vi4x8567, vi4x8567, _MM_SHUFFLE(0, 3, 2, 1));
209 // vi5x5678 = ( vi58, vi57, vi56, vi55 )
210 const __m128 vi5x5678 = _mm_shuffle_ps(vi5x8567, vi5x8567, _MM_SHUFFLE(0, 3, 2, 1));
211
212 vo0p0 = _mm_add_ps(vo0p0, _mm_mul_ps(vi0x5678, vk02));
213 vo1p0 = _mm_add_ps(vo1p0, _mm_mul_ps(vi1x5678, vk02));
214 vo2p0 = _mm_add_ps(vo2p0, _mm_mul_ps(vi2x5678, vk02));
215 vo3p0 = _mm_add_ps(vo3p0, _mm_mul_ps(vi3x5678, vk02));
216 vo0p0 = _mm_add_ps(vo0p0, _mm_mul_ps(vi1x5678, vk12));
217 vo1p0 = _mm_add_ps(vo1p0, _mm_mul_ps(vi2x5678, vk12));
218 vo2p0 = _mm_add_ps(vo2p0, _mm_mul_ps(vi3x5678, vk12));
219 vo3p0 = _mm_add_ps(vo3p0, _mm_mul_ps(vi4x5678, vk12));
220 vo0p0 = _mm_add_ps(vo0p0, _mm_mul_ps(vi2x5678, vk22));
221 vo1p0 = _mm_add_ps(vo1p0, _mm_mul_ps(vi3x5678, vk22));
222 vo2p0 = _mm_add_ps(vo2p0, _mm_mul_ps(vi4x5678, vk22));
223 vo3p0 = _mm_add_ps(vo3p0, _mm_mul_ps(vi5x5678, vk22));
224
225 vi0x4567 = vi0x89AB;
226 vi1x4567 = vi1x89AB;
227 vi2x4567 = vi2x89AB;
228 vi3x4567 = vi3x89AB;
229 vi4x4567 = vi4x89AB;
230 vi5x4567 = vi5x89AB;
231
232
233 __m128 vo0 = _mm_max_ps(vo0p0, vmin);
234 __m128 vo1 = _mm_max_ps(vo1p0, vmin);
235 __m128 vo2 = _mm_max_ps(vo2p0, vmin);
236 __m128 vo3 = _mm_max_ps(vo3p0, vmin);
237
238 vo0 = _mm_min_ps(vo0, vmax);
239 vo1 = _mm_min_ps(vo1, vmax);
240 vo2 = _mm_min_ps(vo2, vmax);
241 vo3 = _mm_min_ps(vo3, vmax);
242
243 _mm_storeu_ps(o3, vo3);
244 o3 += 4;
245 _mm_storeu_ps(o2, vo2);
246 o2 += 4;
247 _mm_storeu_ps(o1, vo1);
248 o1 += 4;
249 _mm_storeu_ps(o0, vo0);
250 o0 += 4;
251 }
252 // Always process the last block of 1..4 pixels.
253 assert(w >= 1 * sizeof(float));
254 assert(w <= 4 * sizeof(float));
255 {
256 vi0x4567 = _mm_and_ps(vmask, vi0x4567);
257 vi1x4567 = _mm_and_ps(vmask, vi1x4567);
258 vi2x4567 = _mm_and_ps(vmask, vi2x4567);
259 vi3x4567 = _mm_and_ps(vmask, vi3x4567);
260 vi4x4567 = _mm_and_ps(vmask, vi4x4567);
261 vi5x4567 = _mm_and_ps(vmask, vi5x4567);
262
263 // vi0x7456 = ( vi06, vi05, vi04, vi07 )
264 const __m128 vi0x7456 = _mm_shuffle_ps(vi0x4567, vi0x4567, _MM_SHUFFLE(2, 1, 0, 3));
265 // vi1x7456 = ( vi16, vi15, vi14, vi17 )
266 const __m128 vi1x7456 = _mm_shuffle_ps(vi1x4567, vi1x4567, _MM_SHUFFLE(2, 1, 0, 3));
267 // vi2x7456 = ( vi26, vi25, vi24, vi27 )
268 const __m128 vi2x7456 = _mm_shuffle_ps(vi2x4567, vi2x4567, _MM_SHUFFLE(2, 1, 0, 3));
269 // vi3x7456 = ( vi36, vi35, vi34, vi37 )
270 const __m128 vi3x7456 = _mm_shuffle_ps(vi3x4567, vi3x4567, _MM_SHUFFLE(2, 1, 0, 3));
271 // vi4x7456 = ( vi46, vi45, vi44, vi47 )
272 const __m128 vi4x7456 = _mm_shuffle_ps(vi4x4567, vi4x4567, _MM_SHUFFLE(2, 1, 0, 3));
273 // vi5x7456 = ( vi56, vi55, vi54, vi57 )
274 const __m128 vi5x7456 = _mm_shuffle_ps(vi5x4567, vi5x4567, _MM_SHUFFLE(2, 1, 0, 3));
275
276 __m128 vo0p0 = _mm_add_ps(vbias, _mm_mul_ps(vi0x4567, vk01));
277 __m128 vo1p0 = _mm_add_ps(vbias, _mm_mul_ps(vi1x4567, vk01));
278 __m128 vo2p0 = _mm_add_ps(vbias, _mm_mul_ps(vi2x4567, vk01));
279 __m128 vo3p0 = _mm_add_ps(vbias, _mm_mul_ps(vi3x4567, vk01));
280 vo0p0 = _mm_add_ps(vo0p0, _mm_mul_ps(vi1x4567, vk11));
281 vo1p0 = _mm_add_ps(vo1p0, _mm_mul_ps(vi2x4567, vk11));
282 vo2p0 = _mm_add_ps(vo2p0, _mm_mul_ps(vi3x4567, vk11));
283 vo3p0 = _mm_add_ps(vo3p0, _mm_mul_ps(vi4x4567, vk11));
284 vo0p0 = _mm_add_ps(vo0p0, _mm_mul_ps(vi2x4567, vk21));
285 vo1p0 = _mm_add_ps(vo1p0, _mm_mul_ps(vi3x4567, vk21));
286 vo2p0 = _mm_add_ps(vo2p0, _mm_mul_ps(vi4x4567, vk21));
287 vo3p0 = _mm_add_ps(vo3p0, _mm_mul_ps(vi5x4567, vk21));
288
289 // vi0x3456 = ( vi06, vi05, vi04, vi03 )
290 const __m128 vi0x3456 = _mm_move_ss(vi0x7456, vi0x3012);
291 // vi1x3456 = ( vi16, vi15, vi14, vi13 )
292 const __m128 vi1x3456 = _mm_move_ss(vi1x7456, vi1x3012);
293 // vi2x3456 = ( vi26, vi25, vi24, vi23 )
294 const __m128 vi2x3456 = _mm_move_ss(vi2x7456, vi2x3012);
295 // vi3x3456 = ( vi36, vi35, vi34, vi33 )
296 const __m128 vi3x3456 = _mm_move_ss(vi3x7456, vi3x3012);
297 // vi4x3456 = ( vi46, vi45, vi44, vi43 )
298 const __m128 vi4x3456 = _mm_move_ss(vi4x7456, vi4x3012);
299 // vi5x3456 = ( vi56, vi55, vi54, vi53 )
300 const __m128 vi5x3456 = _mm_move_ss(vi5x7456, vi5x3012);
301
302 vo0p0 = _mm_add_ps(vo0p0, _mm_mul_ps(vi0x3456, vk00));
303 vo1p0 = _mm_add_ps(vo1p0, _mm_mul_ps(vi1x3456, vk00));
304 vo2p0 = _mm_add_ps(vo2p0, _mm_mul_ps(vi2x3456, vk00));
305 vo3p0 = _mm_add_ps(vo3p0, _mm_mul_ps(vi3x3456, vk00));
306 vo0p0 = _mm_add_ps(vo0p0, _mm_mul_ps(vi1x3456, vk10));
307 vo1p0 = _mm_add_ps(vo1p0, _mm_mul_ps(vi2x3456, vk10));
308 vo2p0 = _mm_add_ps(vo2p0, _mm_mul_ps(vi3x3456, vk10));
309 vo3p0 = _mm_add_ps(vo3p0, _mm_mul_ps(vi4x3456, vk10));
310 vo0p0 = _mm_add_ps(vo0p0, _mm_mul_ps(vi2x3456, vk20));
311 vo1p0 = _mm_add_ps(vo1p0, _mm_mul_ps(vi3x3456, vk20));
312 vo2p0 = _mm_add_ps(vo2p0, _mm_mul_ps(vi4x3456, vk20));
313 vo3p0 = _mm_add_ps(vo3p0, _mm_mul_ps(vi5x3456, vk20));
314
315 const __m128 vzero = _mm_setzero_ps();
316 // vi0x8567 = ( vi07, vi06, vi05, 0.0 )
317 const __m128 vi0x8567 = _mm_move_ss(vi0x4567, vzero);
318 // vi1x8567 = ( vi17, vi16, vi15, 0.0 )
319 const __m128 vi1x8567 = _mm_move_ss(vi1x4567, vzero);
320 // vi2x8567 = ( vi27, vi26, vi25, 0.0 )
321 const __m128 vi2x8567 = _mm_move_ss(vi2x4567, vzero);
322 // vi3x8567 = ( vi37, vi36, vi35, 0.0 )
323 const __m128 vi3x8567 = _mm_move_ss(vi3x4567, vzero);
324 // vi4x8567 = ( vi47, vi46, vi45, 0.0 )
325 const __m128 vi4x8567 = _mm_move_ss(vi4x4567, vzero);
326 // vi5x8567 = ( vi57, vi56, vi55, 0.0 )
327 const __m128 vi5x8567 = _mm_move_ss(vi5x4567, vzero);
328
329 // vi0x5678 = ( vi08, vi07, vi06, vi05 )
330 const __m128 vi0x5678 = _mm_shuffle_ps(vi0x8567, vi0x8567, _MM_SHUFFLE(0, 3, 2, 1));
331 // vi1x5678 = ( vi18, vi17, vi16, vi15 )
332 const __m128 vi1x5678 = _mm_shuffle_ps(vi1x8567, vi1x8567, _MM_SHUFFLE(0, 3, 2, 1));
333 // vi2x5678 = ( vi28, vi27, vi26, vi25 )
334 const __m128 vi2x5678 = _mm_shuffle_ps(vi2x8567, vi2x8567, _MM_SHUFFLE(0, 3, 2, 1));
335 // vi3x5678 = ( vi38, vi37, vi36, vi35 )
336 const __m128 vi3x5678 = _mm_shuffle_ps(vi3x8567, vi3x8567, _MM_SHUFFLE(0, 3, 2, 1));
337 // vi4x5678 = ( vi48, vi47, vi46, vi45 )
338 const __m128 vi4x5678 = _mm_shuffle_ps(vi4x8567, vi4x8567, _MM_SHUFFLE(0, 3, 2, 1));
339 // vi5x5678 = ( vi58, vi57, vi56, vi55 )
340 const __m128 vi5x5678 = _mm_shuffle_ps(vi5x8567, vi5x8567, _MM_SHUFFLE(0, 3, 2, 1));
341
342 vo0p0 = _mm_add_ps(vo0p0, _mm_mul_ps(vi0x5678, vk02));
343 vo1p0 = _mm_add_ps(vo1p0, _mm_mul_ps(vi1x5678, vk02));
344 vo2p0 = _mm_add_ps(vo2p0, _mm_mul_ps(vi2x5678, vk02));
345 vo3p0 = _mm_add_ps(vo3p0, _mm_mul_ps(vi3x5678, vk02));
346 vo0p0 = _mm_add_ps(vo0p0, _mm_mul_ps(vi1x5678, vk12));
347 vo1p0 = _mm_add_ps(vo1p0, _mm_mul_ps(vi2x5678, vk12));
348 vo2p0 = _mm_add_ps(vo2p0, _mm_mul_ps(vi3x5678, vk12));
349 vo3p0 = _mm_add_ps(vo3p0, _mm_mul_ps(vi4x5678, vk12));
350 vo0p0 = _mm_add_ps(vo0p0, _mm_mul_ps(vi2x5678, vk22));
351 vo1p0 = _mm_add_ps(vo1p0, _mm_mul_ps(vi3x5678, vk22));
352 vo2p0 = _mm_add_ps(vo2p0, _mm_mul_ps(vi4x5678, vk22));
353 vo3p0 = _mm_add_ps(vo3p0, _mm_mul_ps(vi5x5678, vk22));
354
355
356 __m128 vo0 = _mm_max_ps(vo0p0, vmin);
357 __m128 vo1 = _mm_max_ps(vo1p0, vmin);
358 __m128 vo2 = _mm_max_ps(vo2p0, vmin);
359 __m128 vo3 = _mm_max_ps(vo3p0, vmin);
360
361 vo0 = _mm_min_ps(vo0, vmax);
362 vo1 = _mm_min_ps(vo1, vmax);
363 vo2 = _mm_min_ps(vo2, vmax);
364 vo3 = _mm_min_ps(vo3, vmax);
365
366 if XNN_LIKELY(w == 4 * sizeof(float)) {
367 _mm_storeu_ps(o3, vo3);
368 o3 += 4;
369 _mm_storeu_ps(o2, vo2);
370 o2 += 4;
371 _mm_storeu_ps(o1, vo1);
372 o1 += 4;
373 _mm_storeu_ps(o0, vo0);
374 o0 += 4;
375 } else {
376 if (w & (2 * sizeof(float))) {
377 _mm_storel_pi((__m64*) o3, vo3);
378 o3 += 2;
379 _mm_storel_pi((__m64*) o2, vo2);
380 o2 += 2;
381 _mm_storel_pi((__m64*) o1, vo1);
382 o1 += 2;
383 _mm_storel_pi((__m64*) o0, vo0);
384 o0 += 2;
385
386 vo0 = _mm_movehl_ps(vo0, vo0);
387 vo1 = _mm_movehl_ps(vo1, vo1);
388 vo2 = _mm_movehl_ps(vo2, vo2);
389 vo3 = _mm_movehl_ps(vo3, vo3);
390 }
391 if (w & (1 * sizeof(float))) {
392 _mm_store_ss(o3, vo3);
393 o3 += 1;
394 _mm_store_ss(o2, vo2);
395 o2 += 1;
396 _mm_store_ss(o1, vo1);
397 o1 += 1;
398 _mm_store_ss(o0, vo0);
399 o0 += 1;
400 }
401 }
402 }
403
404 i0 = (const float*) ((uintptr_t) i4 - input_decrement);
405 i1 = (const float*) ((uintptr_t) i5 - input_decrement);
406 i2 = (const float*) ((uintptr_t) i1 + input_width);
407 i3 = (const float*) ((uintptr_t) i2 + input_width);
408 i4 = (const float*) ((uintptr_t) i3 + input_width);
409 i5 = (const float*) ((uintptr_t) i4 + input_width);
410
411 o0 = o3;
412 o1 = (float*) ((uintptr_t) o0 + input_width);
413 o2 = (float*) ((uintptr_t) o1 + input_width);
414 o3 = (float*) ((uintptr_t) o2 + input_width);
415
416 output_height = doz(output_height, 4);
417 } while (output_height != 0);
418 }
419