Debian Codegraph @

src/f32-rminmax/gen/f32-rmax-sse-u16-acc4.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-rminmax/sse.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2023 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/common.h"
15 #include "xnnpack/reduce.h"
16
17
18 void xnn_f32_rmax_ukernel__sse_u16_acc4(
19 size_t batch,
20 const float* input,
21 float* output,
22 const struct xnn_f32_default_params params[restrict XNN_MIN_ELEMENTS(1)])
23 {
24 assert(batch != 0);
25 assert(batch % sizeof(float) == 0);
26 assert(input != NULL);
27 assert(output != NULL);
28
29 __m128 vmax0 = _mm_load_ss(input);
30 vmax0 = _mm_shuffle_ps(vmax0, vmax0, _MM_SHUFFLE(0, 0, 0, 0));
31 __m128 vmax1 = vmax0;
32 __m128 vmax2 = vmax0;
33 __m128 vmax3 = vmax0;
34 for (; batch >= 16 * sizeof(float); batch -= 16 * sizeof(float)) {
35 const __m128 vt0 = _mm_loadu_ps(input);
36 const __m128 vt1 = _mm_loadu_ps(input + 4);
37 const __m128 vt2 = _mm_loadu_ps(input + 8);
38 const __m128 vt3 = _mm_loadu_ps(input + 12);
39 input += 16;
40
41 vmax0 = _mm_max_ps(vmax0, vt0);
42 vmax1 = _mm_max_ps(vmax1, vt1);
43 vmax2 = _mm_max_ps(vmax2, vt2);
44 vmax3 = _mm_max_ps(vmax3, vt3);
45 }
46 vmax0 = _mm_max_ps(vmax0, vmax1);
47 vmax2 = _mm_max_ps(vmax2, vmax3);
48 vmax0 = _mm_max_ps(vmax0, vmax2);
49 for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) {
50 const __m128 vt = _mm_loadu_ps(input);
51 input += 4;
52
53 vmax0 = _mm_max_ps(vmax0, vt);
54 }
55 if XNN_UNLIKELY(batch != 0) {
56 do {
57 const __m128 vt = _mm_load_ss(input);
58 input += 1;
59 vmax0 = _mm_max_ss(vmax0, vt);
60 batch -= sizeof(float);
61 } while (batch != 0);
62 }
63 vmax0 = _mm_max_ps(vmax0, _mm_movehl_ps(vmax0, vmax0));
64 vmax0 = _mm_max_ss(vmax0, _mm_shuffle_ps(vmax0, vmax0, _MM_SHUFFLE(1, 1, 1, 1)));
65 _mm_store_ss(output, vmax0);
66 }