Debian Codegraph @

src/f32-rminmax/gen/f32-rminmax-wasmsimd-minmax-u8-acc2.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-rminmax/wasmsimd.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 <wasm_simd128.h>
13
14 #include "xnnpack/common.h"
15 #include "xnnpack/reduce.h"
16
17
18 void xnn_f32_rminmax_ukernel__wasmsimd_minmax_u8_acc2(
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 v128_t vmin0 = wasm_v128_load32_splat(input);
30 v128_t vmax0 = vmin0;
31 v128_t vmin1 = vmin0;
32 v128_t vmax1 = vmax0;
33 for (; batch >= 8 * sizeof(float); batch -= 8 * sizeof(float)) {
34 const v128_t vt0 = wasm_v128_load(input);
35 const v128_t vt1 = wasm_v128_load(input + 4);
36 input += 8;
37
38 vmin0 = wasm_f32x4_min(vmin0, vt0);
39 vmax0 = wasm_f32x4_max(vmax0, vt0);
40 vmin1 = wasm_f32x4_min(vmin1, vt1);
41 vmax1 = wasm_f32x4_max(vmax1, vt1);
42 }
43 vmin0 = wasm_f32x4_min(vmin0, vmin1);
44 vmax0 = wasm_f32x4_max(vmax0, vmax1);
45 for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) {
46 const v128_t vt = wasm_v128_load(input);
47 input += 4;
48
49 vmin0 = wasm_f32x4_min(vmin0, vt);
50 vmax0 = wasm_f32x4_max(vmax0, vt);
51 }
52 vmin0 = wasm_f32x4_min(vmin0, wasm_v64x2_shuffle(vmin0, vmin0, 1, 1));
53 vmax0 = wasm_f32x4_max(vmax0, wasm_v64x2_shuffle(vmax0, vmax0, 1, 1));
54 if XNN_UNLIKELY(batch & (2 * sizeof(float))) {
55 const v128_t vt = wasm_v128_load64_zero(input);
56 input += 2;
57 vmin0 = wasm_f32x4_min(vmin0, vt);
58 vmax0 = wasm_f32x4_max(vmax0, vt);
59 }
60 vmin0 = wasm_f32x4_min(vmin0, wasm_v32x4_shuffle(vmin0, vmin0, 1, 1, 1, 1));
61 vmax0 = wasm_f32x4_max(vmax0, wasm_v32x4_shuffle(vmax0, vmax0, 1, 1, 1, 1));
62 if XNN_UNLIKELY(batch & (1 * sizeof(float))) {
63 const v128_t vt = wasm_v128_load32_zero(input);
64 vmin0 = wasm_f32x4_min(vmin0, vt);
65 vmax0 = wasm_f32x4_max(vmax0, vt);
66 }
67 wasm_v128_store32_lane(output, vmin0, 0);
68 wasm_v128_store32_lane(output + 1, vmax0, 0);
69 }